O'Reilly logo

Learning Angular for .NET Developers by Rajesh Gunasundaram

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Setting up a Component Router

A Component Router is not part of the core Angular framework. It comes as part of the Angular NPM bundle as an individual library, @angular/router. We need to add @angular/router to the packages.json under the dependencies section. Then, in the app.routing.ts, we need to import Routes and RouterModule from @angular/router. The router constitutes directives such as RouterOutlet, RouterLink, and RouterLinkActive, a service RouterModule and the configuration for Routes.

Then, we need to add the <base> element under <head> to instruct the router to set up navigation URLs. The following code snippet shows the <base> tag with the href attribute that is to be added to the head tag in the index file, considering that ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required