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

Configuring routes

The routes have information about selecting the view to render when a user clicks on a link for navigation. The following code snippet shows how to configure routes in app.module.ts:

import { RouterModule } from '@angular/router';RouterModule.forRoot([{  path: 'about',  component: AboutComponent},{  path: 'contact',  component: ContactComponent}])

Here, we have configured two routes that help the user navigate to the about and contact views when clicked on. Routes are basically a collection of route definitions. The value of the path defined identifies the component to be instantiated when the URL in the browser matches the path. Then, the instantiated component will take care of rendering the view.

Now, we need to add the ...

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