Angular的子路线无效

时间:2018-07-30 12:27:50

标签: angular

为什么有人可以帮助我,我陷入了有角的6条儿童路线。我的有角子路径无法在懒惰负载下工作。

这是我的应用程序路由模块

import { NgModule } from '@angular/core';
import { Routes, RouterModule, PreloadAllModules } from '@angular/router';


const routes: Routes = [
  { path: '', redirectTo: '/dashboard', pathMatch: 'full' },
  {
    path: 'master',
    loadChildren: './modules/master/master.module#MasterModule'
  },
];

@NgModule({
  imports: [RouterModule.forRoot(routes, {
    // preload all modules; optionally we could
    // implement a custom preloading strategy for just some
    // of the modules (PRs welcome )
    preloadingStrategy: PreloadAllModules
  })],
  exports: [ RouterModule ]
})

export class AppRoutingModule { }

然后,这是我的主路由模块

import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';

import { DokterComponent } from './dokter/dokter.component';
import { MasterComponent } from './master.component';

const routes: Routes = [  
  {
    path: '',
    component: MasterComponent
    children: [
      { path: "", component: DokterComponent, pathMatch: "full" },
    ]
  }
];

@NgModule({
  imports: [RouterModule.forChild(routes)],
  exports: [RouterModule]
})
export class MasterRoutingModule { }

当我尝试访问/ master / dokter时,没有错误消息,但是dokterComponent无法加载。感谢您的关注。

0 个答案:

没有答案