Reputation: 2780
What I'm trying to make is a comparator for statusus, I made an array of names for the names of the channels that I want to compare:
var stations = [
"BasicChannel",
"PixelChannel",
"GoldenChannel"
];
Now, through using a foreach loop I want to do a HTTP call with all of those statusus:
angular.forEach(stations, function(channel) {
$http({
method: "GET",
url: channel + ".php"
}).success(function(data) {
data.name = channel;
$scope.channels = data;
});
});
Now, the problem is that I have is that every time I do a HTTP call, it overrides the other ones.
Is there a way to get these in an object, or an array maybe?
Thanks.
Upvotes: 0
Views: 27
Reputation: 931
It can insert the data at top of the array.
$scope.channels.unshift(data);
Upvotes: 0
Reputation: 2146
You can concatenate two array in Javascript. Like this:
$scope.channels.concat(data);
Upvotes: 1