In the entry I wrote yesterday I wasn’t very fair. The fake asynchronous code I used to simulate a 1 second delay was using Angular’s $timeout service which makes the promises work 100% of the time.

However in a real world application this might not be so straightforward and you might come to a point when you don’t know why your promises are not being resolved and your callbacks never triggered.

This happened to me yesterday and it took me a while to realize the reason: In AngularJS the results of promise resolution are propagated asynchronously, inside a $digest cycle. So, callbacks registered with then() will only be called upon entering a $digest cycle.

What this means is that if the callback inside the .then() function is triggered outside a $digest cycle, then it will never be called and your promise will seem to not been resolved ever.

To work around this problem you will need to surround your promise resolve method with either a $timeout or a $scope.$apply if applicable. This way your promises will always be inside the Angular Universe and your callbacks will be invoked correctly.

I’ve updated yesterday’s plunker with some better cleaner nicer code, because it was bothering me.