應用程序運行正常,但上傳子路由也可以不經過'/ upload'訪問。例如'/ photo','/ advertisement'。這不應該發生。我不知道爲什麼會發生這種情況。如果有人知道解決方案,請回復。如何在角4.3.1中實現嵌套的延遲加載?
app.routing.ts
{ path: '', redirectTo: '/dashboard', pathMatch: 'full'},
{path: '', loadChildren: 'app/campsite/campsite.module#CampsiteModule'},
{path: 'login', loadChildren: 'app/login/login.module#LoginModule'}
campsite.routing.ts
path: '', component: CampsiteComponent, children: [
{path: 'dashboard', component: HomeComponent, canActivate: [AuthGuard]},
{path: 'gallery', component: GalleryComponent, canActivate: [AuthGuard]},
{path: 'upload', loadChildren: './upload/upload.module#UploadModule', canActivate: [AuthGuard]}
]
upload.routing.ts
path: '', component: UploadComponent, children: [
{path: 'photo', component: PhotoComponent, canActivate: [AuthGuard]},
{path: 'advertisement', component: AdvertisementComponent, canActivate: [AuthGuard]},
{path: 'video', component: VideoComponent, canActivate: [AuthGuard]},
{path: 'logo', component: LogoComponent, canActivate: [AuthGuard]},
{ path: 'photo', pathMatch: 'full', redirectTo: 'photo' }
]
Lazy Component Upload is loading in App Component Routing too
儘管如此,試試Angular 4.3.6。 :) – Gustave
如果我遵循上述兩個步驟,那麼它不能再延遲加載。它發生的角度相同4.3.6 – Garima
我看到 - 你懶惰地加載模塊兩次。 :)(我需要更多的咖啡,並且我切換到了decaf,這顯然不起作用。) – Gustave