I gave you an overview about routing in Angular. In this tutorial, we will apply it to our Questions Management application. First, I will create a new module called AppRoutingModule in the app-routing.module.ts file in the src/app directory: with the following content:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; import { DashboardComponent } from './dashboard/dashboard.component'; const routes: Routes = [ { path: '', component: DashboardComponent }, { path: 'dashboard', component: DashboardComponent }, { path: '**', pathMatch: 'full', redirectTo: '/' } ] @NgModule({ imports: [ RouterModule.forRoot(routes) ], exports: [ RouterModule ] }) export class AppRoutingModule { } |
As you… Read More