How can I call the second sequential promise design pattern method in a loop in angularjs? [duplicate]
问题 This question already has answers here : JavaScript closure inside loops – simple practical example (44 answers) Closed 3 years ago . New to angularjs and trying out the promise pattern for the first time - I have a service utility inside which I have this method - this.getData= function(url){ var defer = $q.defer(); $http({method: 'GET', url: url}). success(function(data, status){ defer.resolve(data); }) .error(function(data, status) { defer.reject(status); }); return defer.promise; }; Now