Chapter 5. Integrating Node with Angular

Now that you’ve built your API, it’s time to use it with Angular. Also, since Node is a web server, it’d be nice to get it to serve your HTML rather than load it as a flat file like you’ve been doing thus far.

$http

To perform HTTP calls in Angular, you’ll use its built-in HTTP client: $http. If you haven’t noticed yet, official Angular components start with $. You should not prefix components you create with a $.

$http is a pretty standard HTTP client with some of the usual suspects: $http.get(), $http.post(), and so on. It is promise based.

What Are Promises?

Promises are a way of writing asynchronous code in JavaScript as an alternative to the traditional callback method that Node uses.

If you look ...

Get Write Modern Web Apps with the MEAN Stack: Mongo, Express, AngularJS, and Node.js 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.