O'Reilly logo

Write Modern Web Apps with the MEAN Stack: Mongo, Express, AngularJS, and Node.js by Jeff Dickey

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required