Uncaught (in promise): Error: Cannot match any routes. URL Segment: Angular

后端 未结 2 509
迷失自我
迷失自我 2021-01-28 17:37

I am new to Angular. I am using Angular 7 and doing a simple routing. After Login page, I want to display a home page. Login is a part of app-root component and in

相关标签:
2条回答
  • 2021-01-28 18:18

    it should be like this in your dashboard-routing-module.ts:

    const routes: Routes = [{
      path: '',
      component: DashBoardComponent,
      children: [
       {
          path: '',
          redirectTo: 'home',
          pathMatch: 'prefix'
       },
       {
          path: 'home',
          component: HomeComponent
       }
     ]
    }];
    
    0 讨论(0)
  • 2021-01-28 18:22

    you must use this code :

    this._router.navigate(['/dashboard/home']);
    

    if it doesn't work, in "dashboard-routing.modul.ts" file use path: ' ', instead of
    path: 'dashboard',.

    0 讨论(0)
提交回复
热议问题