Here I created sample for services call which is Working fine Call one by one Link for sample.
like this:-
JSONService.getJSON('file.json').then(function(data){
$scope.languages = data;
});
JSONService.getJSON('file1.json').then(function(data){
$scope.languages1 = data;
});
I don't want to send separately. why because if its only two three call means fine.but I need to do more than 100 calls. that time I can't do one by one. so tried like this
JSONService.getJSON('file.json,file1.json').then(function(data){
$scope.languages = data[0];
$scope.languages1 = data[1];
});
In services use split the values and try to push the promise one by one and return as array its not working I don't know where i did mistake can any one help me on this..
app.service('JSONService', function($http){
var data = [];
return{
getJSON: function(url){
var parameter=url.split(',');
for(var i=0; i< parameter.length; i++){
$http.get(parameter[i])
.then(function(response){
data.push(response);
});
}
return data;
}
};
});
$scopehere? :{ I would probably also accept an Array from the get-go,getAwesomeFiles(['json1', 'json2', ..])