【发布时间】:2020-06-22 09:28:15
【问题描述】:
我有一个非常简单的项目设置,但是我无法使用 loadchildren 导航到延迟加载路径...
app-routing.module.ts:
const routes: Routes= [
{path:'', redirectTo: 'auth', pathMatch: 'full'},
{path:'auth', component: AnmeldungComponent},
{path:'system', loadChildren: '~/app/system/system.module#SystemModule'},
{path:'settings', component: SettingsComponent}
];
@NgModule({
imports: [NativeScriptRouterModule.forRoot(routes)],
exports: [NativeScriptRouterModule]
})
export class AppRoutingModule {}
系统路由.module.ts:
const routes: Routes = [
{
path: "",
component: ListeSystemComponent,
},
{ path: "monitorliste", component: ListeMonitorComponent },
{ path: "messwerte/:id", component: DatenMonitordatenComponent },
{
path:
"messwertverlauf/:schwelleAlert/:schwelleGut/:schwelleWarn/:schwelleRichtung/:id",
component: MesswertverlaufComponent,
},
];
@NgModule({
imports: [NativeScriptRouterModule.forChild(routes)],
exports: [NativeScriptRouterModule],
})
export class SystemRoutingModule {}
list-monitor.component.ts:
onItemTap(currentMonitorListeElem: MonitorListeElem){
this.routerExt.navigate(['messwerte',currentMonitorListeElem.id ], {transition: {name: 'slideLeft'}, relativeTo: this.route});
}
当执行onItemTap 函数时,我得到错误:
错误:无法匹配任何路由。 URL 段:'system/monitorliste/messwerte/421'
这不是完全正确的路线还是我完全错误的理解?
非常感谢!
编辑: 编辑 system-routing.module.ts:
const routes: Routes = [
{
path: "",
component: ListeSystemComponent,
children: [
{
path: "monitorliste",
component: ListeMonitorComponent,
children: [
{
path: "messwerte/:id",
component: DatenMonitordatenComponent,
},
{
path:
"messwertverlauf/:schwelleAlert/:schwelleGut/:schwelleWarn/:schwelleRichtung/:id",
component: MesswertverlaufComponent,
},
],
},
],
},
];
当我这样使用它时,我什至无法到达“monitorliste”,我被困在“系统”中
使用时:
系统路由.module.ts:
const routes: Routes = [
{
path: "",
component: ListeSystemComponent,
},
{
path: "monitorliste",
component: ListeMonitorComponent,
children: [
{
path: "messwerte/:id",
component: DatenMonitordatenComponent,
},
{
path:
"messwertverlauf/:schwelleAlert/:schwelleGut/:schwelleWarn/:schwelleRichtung/:id",
component: MesswertverlaufComponent,
},
],
},
];
我可以到达“monitorliste”,但我无法到达“messwerte/:id”,而是被重定向到“monitorliste”
【问题讨论】:
-
在 Angular 8 中延迟加载更改:angular.io/guide/lazy-loading-ngmodules(无论如何,在 Angular 7 中,我认为您需要使用点 .,也不是 ~
标签: angular angular-ui-router nativescript lazy-loading