angular 2

URL Routing for a Decoupled App, with Angular 2 and Django

Lately, I have worked on a few projects where a single-page Angular app is contained within a site built on a server-side framework like Django. One of the challenges is to get their URLs to play nicely together.

Say you have a project with an Angular 2 front end and an API back end using the Django Rest Framework. Further, imagine that your Angular 2 page is also served from within the Django app. Your URL structure might look like this:

Angular 2: Using the HTTP Service to Write Data to an API

In my previous article, Angular 2: HTTP, Observables, and concurrent data loading, we investigated querying data from an API endpoint using Angular 2's Http service and the Observable pattern. In this second article, we will look at using Http to save data to our API endpoint.

Consider the Angular 2 service we created in the previous article, DemoService:

Angular 2: HTTP, Observables, and concurrent data loading

Angular 2 provides a new pattern for running asynchronous requests, called Observables. Here, we will review a few of the concepts and eventually see how to run multiple concurrent HTTP requests, with the callbacks running only after all of them have completed.

Author's note, November 24, 2016: Updated for final Angular 2.0 API. Updated on June 5, 2017.