Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49087

Loop $http

$
0
0

@Vieroli wrote:

Hello everyone,

this is my code :

$http.get('lienversmonapi?level='+niveau[0]+'&value='+valeur[0]).then(function(response){
    $scope.element0 = response.data;
});
$http.get('lienversmonapi?level='+niveau[1]+'&value='+valeur[1]).then(function(response){
    $scope.element1 = response.data;
});
$http.get('lienversmonapi?level='+niveau[2]+'&value='+valeur[2]).then(function(response){
    $scope.element2 = response.data;
});
$http.get('lienversmonapi?level='+niveau[3]+'&value='+valeur[3]).then(function(response){
    $scope.element3 = response.data;
});
$http.get('lienversmonapi?level='+niveau[4]+'&value='+valeur[4]).then(function(response){
    $scope.element4 = response.data;
});

I would like to know, how I can do to avoid to write 5 times the same code..

I've tried a for loop, but it didn't work..

Thanks for helping !

Posts: 3

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 49087

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>