One of the most common questions I see on StackOverflow regarding Angular, are questions involving the creation of AJAX-based angular services using $http. Commonly the pattern used is very reminiscent of JQuery, where there's a method with a callback when the data is received.
In Angular, there is a service called $q. It is a deferred/promise implementation built off of Q by Kristopher Kowal.
Promises get special treatment in Angular however, because when a promise is resolved, Angular will trigger a digest, and any scope properties that contain a promise will be evaluated for that promise's resolved value. So in code, that means if you return a promise from your service, and put it directly in a scope property, it will asynchronously update that scope property and process the changes.
Your new post is loading...