Talking to the backend

So now we need to connect our frontend to our backend. Instead of rendering data in our page on load, we want to use AJAX to connect and do all of our CRUD. Fortunately for us, Angular has a pretty elegant way of handling this.

Creating an AngularJS factory

Let's say that different parts of our application may need access to some of the same data endpoints, or some other functionality. A great way to handle this is with an AngularJS provider. A provider is essentially an injectable singleton, and there are a number of options available - see

The provider type we are going to use is a factory. Let's start by creating a services directory inside our public/javascripts directory. Create ...

Get Mastering JavaScript Single Page Application Development 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.