Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Macro is JavaScript
Message
De
09/02/2015 15:04:45
 
 
Information générale
Forum:
Javascript
Catégorie:
Autre
Divers
Thread ID:
01615034
Message ID:
01615037
Vues:
42
J'aime (1)
Does

IndexStr = index.toString();
$scope.currentTemplate["aAutoDep"+IndexStr] = '';


work?

>Hi everybody,
>
>I have the following code (for 6 values of the indexes):
>
>
>if (index === 1) {
>                        $scope.currentTemplate.aAutoDep1 = '';
>                        $scope.currentTemplate.aAutoItm1 = '';
>                        $scope.currentTemplate.aAutoCat1Hashed = null;
>                        $scope.currentTemplate.aAutoCat1 = '';
>                    } else if (index === 2) {
>                        $scope.currentTemplate.aAutoDep2 = '';
>                        $scope.currentTemplate.aAutoItm2 = '';
>                        $scope.currentTemplate.aAutoCat2Hashed = null;
>                        $scope.currentTemplate.aAutoCat2 = '';
>
>Is there a way to write it in a simpler manner without 6 different cases?
>
>Thanks in advance.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform