Java Trainer At Naresh IT
hi. sir subbareddy here ur student. can u pls upload single page application ui-router example.
angular.module('myApp').service('MyService', function($q, $resource) { var getResult = function() { var fullResult = $q.defer(); $resource('url').get().$promise.then(function(data) { var partialPromises = []; for (var i = 0; i < data.elements.length; i++) { var ires = $q.defer(); partialPromisses.push(ires); $resource('url2').get().$promise.then(function(data2) { //do whatever you want with data ires.resolve(data2); }); $q.all(partialPromisses).then(function() { fullResult.resolve(data); }); return fullResult.promise; // or just fullResult } }); }; return { getResult: getResult };});AngularJS Training in Chennai
hi. sir subbareddy here ur student. can u pls upload single page application ui-router example.
ReplyDeleteangular.module('myApp').service('MyService', function($q, $resource) {
ReplyDeletevar getResult = function() {
var fullResult = $q.defer();
$resource('url').get().$promise.then(function(data) {
var partialPromises = [];
for (var i = 0; i < data.elements.length; i++) {
var ires = $q.defer();
partialPromisses.push(ires);
$resource('url2').get().$promise.then(function(data2) {
//do whatever you want with data
ires.resolve(data2);
});
$q.all(partialPromisses).then(function() {
fullResult.resolve(data);
});
return fullResult.promise; // or just fullResult
}
});
};
return {
getResult: getResult
};
});
AngularJS Training in Chennai