错误错误:未捕获(承诺):错误:无法匹配任何路由。网址段:“仪表板/用户/添加用户”

时间:2018-09-17 08:10:55

标签: angular angular-material angular-cli angular6

所以我的问题是我无法访问路径'/ dashboard / users / add-user'或users-routing.module.ts中的任何其他路由(默认(空)路由除外),并且卡住了上述错误。需要一些来逃避这个。下面是我的代码的一些必要部分。

app-routing.module.ts:

const routes: Routes = [
  { path: 'dashboard', loadChildren: './dashboard/dashboard.module#DashboardModule', data: {title:'Dashboard'} },
  { path: '', redirectTo: '/dashboard/transactions', pathMatch: 'full' },
]

dashboard-routing.module.ts

const routes: Routes = [
  {
    path: '', component: DashboardComponent, children: [
      { path: 'users', pathMatch: 'full', loadChildren: './users/users.module#UsersModule',data:{title:'Users'} },
]
}]

users-routing.module.ts

const routes: Routes = [
    { path:'', component:UsersLandingComponent },
    { path:'add-user', component:AddUserComponent, pathMatch:'full', data:{title: 'Add User'}}
]

dashboard.component.html

<nav mat-tab-nav-bar color="accent">
  <a mat-tab-link *ngFor="let link of navLinks; let i = index" [routerLink]="link.path" routerLinkActive #rla="routerLinkActive" [active]="activeLinkIndex === i"
  (click)="activeLinkIndex = i">{{link.label}}</a>
</nav>
<router-outlet></router-outlet>

0 个答案:

没有答案