Router navigate to child route - Angular 6

后端 未结 6 587
半阙折子戏
半阙折子戏 2021-01-17 21:54

I\'ve defined my routes like this:

const routes: Routes = [
    { path: \'\', loadChildren: \'./tabs/tabs.module#TabsPageModule\' },
    { path: \'faq\', lo         


        
6条回答
  •  北荒
    北荒 (楼主)
    2021-01-17 22:37

    If you want to navigate to the list route you need to make the angular know that its a child route of tabs

    this.router.navigate(['/tabs/list']); or this.router.navigate(['tabs','list']);

    In router navigate you need to pass routes as an array of string so now the angular will find for the parent tabs and checks the child route if it is nothing it will navigate to pathMatch: 'full' if not it will navigate to the specific child route

    In routerLink you can use the same array to match the route

    Thanks, Happy coding !!

提交回复
热议问题