Implementing a Database Access Service

In this example you will build an intermediate database access service that uses the $http service to connect to a simple Node.js server that will act as a server-side database service. The purpose of this exercise is to illustrate the usage of built-in services alongside custom services. This also gives a good example of utilizing the $q service.

Listing 10.5 implements the Node.js web server that handles the following GET and POST routes to get and set a user object and an array of table data to simulate making requests to a remote database service:

/get/user: A GET route that returns the JSON version of a user object.

/get/data: A GET route that returns the JSON version of an array of table data. ...

Get Learning AngularJS 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.