The Angular Router enables navigation from one view to the next as users perform application tasks. Routes tell the router which view to display when a user clicks a link or pastes a URL into the browser address bar.
3. Routing
1. Set base tag in index.html
2. Configure routes
3. Tying routes to actions
4. Placing the views
4. Set base tag in index.html
If you used the angular-cli to create the project you're working with, it will
automatically add this in the head tag. If it's not there, add it:
5. Configure routes
1. Import RouterModule in app.module.ts
2. Add RouterModule to the @NgModule.imports array and configure it with the routes in
one step by calling RouterModule.forRoot()
3. RouterModule.forRoot([{ path: welcome, component: WelcomeComponent } ])
6.
7. RouterModule.forRoot([
{ path: 'product', component : ProductListComponent },
{ path: 'welcome', component : WelcomeComponent },
])
A typical Angular Route has two properties:
1. path: a string that matches the URL in the browser address bar.
2. component: the component that the router should create when navigating to this route.