Using promises with $resource

As part of the ngResource module, $resource provides a service to manage connections with RESTful resources. As far as vanilla AngularJS goes, this is in some ways the closest you'll get to a formal data object model infrastructure. The $resource tool is highly extensible and is an excellent standalone tool upon which to build applications if third-party libraries like Restangular aren't your cup of tea.

As the API-focused wrapper for $http, $resource also provides an interface for using promises in conjunction with the HTTP requests that it generates.

How to do it…

Although it wraps $http, $resource actually does not use promises in its default implementation. The $promise property can be used to access the promise ...

Get AngularJS Web Application Development Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.