# Category: angular-promise

## Angular success function called before http.get function returns

I have an angular controller which makes an HTTP GET request and on the promise return, calls either a success of error function. My code right now will sometimes execute the success function after the GET request returns and sometime execute before it. Is there something I’m messing up in my promise handling? Something to note, sometimes the http GET doesn’t even get called (or at least its breakpoint) and the success function happens regardless. […]

## Calling $http inside angularjs watch from a directive I am trying to call$http service from inside a watch in my directive. Assuming, the directive is put on more than one input element. If the value of all elements changes together, the watches fire back to back and $http gets called back to back as well, sometimes messing up the response for each$http call, i.e for consecutive $http calls, even though the inputs are different response comes the same. What is the […] ## Karma-Jasmine async test returns Error: Timeout – Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL [duplicate] This question already has an answer here: Unit testing an asynchronous service in angularjs 2 answers I am currently writting tests for one of my AngularJS services in which I have async methods. In my Jasmine test the method is correctly called but I can’t retrieve the promise and I get the following error message : Error: Timeout – Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL. I’ve tested to change the timeout […] ## Worker JS only return promise one time I’m trying to implement a worker. I have an Angular JS application and the factory calls the worker to update the frontend based on a json change. My worker is working correctly, it’s running every 20 seconds, but the first JSON change it works, so, it means, I have a promise (as worker answer) and the controller get the promise. But… the worker continue working, it gets the differences but the factory doesn’t return the […] ## Firebase$loaded() on $firebaseArray() I am using AngularFire and promises on arrays ($loaded() on firebaseArray()). Currently, I’m using the following code: Problem: I go to page1, the data is loaded and all fine. Go to page 2 and come back to page1. Now the $loaded() doesn’t work until I do a full page refresh. How do I fix this problem? app.factory(‘Items’, [‘FBURL’, ‘$firebaseArray’, function(FBURL, $firebaseArray) { return { ofCategory: function(catId){ var ref = new Firebase(FBURL); var refSearch = new […] ## AngularJS with$q data lost when chaining promises

In the following code I want to execute a series of $http requests that modify a list. When all the responses are received, I want to process the list and remove part of the content. The problem is that when I print the list after$q.all, the Chrome console shows a length of 3, but when I expand it to read the content only 2 elements are shown. On JSFiddle I have no issues, though. […]