使用子路由:错误错误:未捕获(承诺):错误:无法匹配任何路由。网址段

问题描述 投票:0回答:1

我收到此错误,却不知道为什么。我希望你能帮助我。我用“ Localhost:4200 / Admin / Lastrecords”调用了URL。

错误错误:未捕获(已承诺):错误:无法匹配任何路由。 URL段。“最后记录”

parent.module

@NgModule({
  declarations: [
    AppComponent,
    InfoComponent,
    LoginComponent,
    ProtectedComponent,
    DropdownDirective,
    MainComponent
  ],
  imports: [
    BrowserModule,
    routing,],
    ...
    export class AppModule { }

父路由器

const APP_ROUTES: Routes = [
    {path: '', component: LoginComponent},
    {path: 'Admin', component: DashboardComponent, loadChildren: './admin/admin.module#AdminModule'},
];

export const routing = RouterModule.forRoot(APP_ROUTES);

child.module

@NgModule({
  declarations: [
    DashboardComponent,
    NewAccComponent,
    KeyComponent,
    LastLoginComponent,
    RecordComponent
  ],
  imports: [
    routdash,
    FormsModule,
  ],

   export class AdminModule {

}

child.routing

const DASH_ROUTES: Routes = [
  {path: '', component: LastLoginComponent, outlet: 'sec'},
  {path: 'Lastlogins', component: LastLoginComponent, outlet: 'sec'},
  {path: 'Lastrecords', component: RecordComponent, outlet: 'sec'},
];

export const routdash = RouterModule.forChild(DASH_ROUTES);
angular parent-child router
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.