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