Skip to content Skip to sidebar Skip to footer

The Promise Of A Promise Again (Angular JS)

Updated with HTTP and initial code based on requests/Please look at the bottom of the post: I've been posting several questions on my AngularJS learning curve of late and the SO co

Solution 1:

I finally solved all the problems. There were various issues with my initial attempts. My final resolved solution is here Am I returning this promise correctly?

The learnings:

a) Separating the HTTP get into a factory and the data model into another service was unnecessarily complicating life. But that separation was not the problem. Infact, the way the promise was coded above, on first run, if monitorsLoaded was 0, it would simply return the deferred promise and there was no ".success" or similar construct for me to get into the resolve code block again.

b) The biggest thing that was making me run around in loops was deferring or rejecting was simply setting a state. the return always has to be the promise - and it would return the state you set. I assumed return d.promise always means returning "in progress".


Post a Comment for "The Promise Of A Promise Again (Angular JS)"