Creating an Angular app with routing
Whenever we have created a new Angular app through the course of this book so far, the Angular CLI has asked us whether we wanted to add routing, and we have always replied no. Well, it is time to respond positively and enable routing to our Angular app! In the following sections, we will put into practice all the basics that we have learned about routing:
- Scaffolding an Angular 10 app with routing
- Adding route configuration to our Angular app
- Navigating to application routes
At the end of this section, we will have built a simple Angular 10 app with complete routing capabilities.
Scaffolding an Angular app with routing
We are going to use the Angular CLI to create a new Angular 10 app from scratch:
- Execute the
ng new
Angular CLI command to create an Angular app namedmy-app
. - Type
y
(yes) to the question asking whether we would like to add routing to our app, and then press Enter. - Accept the default
CSS...