Angular routing

In Chapter 10, Modularization, under the Using Express with Node section, we explored how an Express server uses routing in order to generate different pages based on the URL that was entered into the browser. We also showed how we can get Express to redirect the browser to a different page based on whether a user was logged in or not. Our Angular application, however, is a Single Page Application (SPA), so we need to implement any page navigation based on a URL within Angular itself. In order to do this, we will use Angular routing.

Angular routing is similar to Express routing, where we define what routes we need, and then attach a class to handle this route. To set up routing within Angular, let's create a file named

Get Mastering TypeScript 3 - Third Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.