I have an AngularJS service that I want to initialize with some asynchronous data. Something like this: myModule.service('MyService', function($http) { var myData = null; $http.get('data.json').success(function (data) {...
I have seen answers on StackOverflow where people suggest furnishing a callback function to an AngularJS service. app.controller('tokenCtrl', function($scope, tokenService) { tokenService.getTokens(function callbackFn(tokens) {...
I want to implement a dynamic loading of a static resource in AngularJS using Promises. The problem: I have couple components on page which might (or not, depends which are displayed, thus dynamic) need to get a static resource from the server. Onc...
This question already has answers here:...
This question already has an answer here:...
I have a list of objects. The objects are passed to a deferred function. I want to call the function with the next object only after the previous call is resolved. Is there any way I can do this? angular.forEach(objects, function (object) { // w...
In the following code, an exception is caught by the catch function of the $q promise: // Fiddle - http://jsfiddle.net/EFpn8/6/ f1().then(function(data) { console.log("success 1: "+data) return f2(); }) .then(function...
I want to know if it is possible to make a service call that uses $http so it returns data directly without returning a promise? I have tried to use the $q and defer without any luck. Here is what I mean: I have a service: angular.module('myMo...
I'm trying to use the Pinterest JavaScript SDK to get some pin data for a project. I have a method in a Pinterest service I created that gets called in my HomeController. I tried throwing the response inside of a promise so I could put it on my H...
This question already has answers here:...
©2020 All rights reserved.