2 ms·
I've been writing a fair amount of AngularjS code recently and have been dealing with this issue. Angular has a $q service [1] for deferred actions, which is a
by cletus 14y ago
I've been writing a fair amount of AngularjS code recently and have been dealing with this issue. Angular has a $q service [1] for deferred actions, which is a cutdown version of the Q library [2]. I like it a lot.
The nice thing about Angular is that the use of promises is pervasive (eg the $http service) and Angular understands them so:
$scope.projects = $http.get('/projects');
and a template of:
<ul>
<li ng-repeat="project in projects">
{{ project }}
</li>
</ul>
where $http.get() returns a promise just works.
[1]: http://docs.angularjs.org/api/ng.$q http://docs.angularjs.org/api/ng.$q
[2]: https://github.com/kriskowal/q https://github.com/kriskowal/q