我有一个可能非常简单的问题,但我无法弄清楚我犯了什么错误。
我尝试在我的 Nativescript 应用程序中实现延迟加载。
应用程序路由.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 {}
我知道我已经在使用.forChild(routes)
我认为它不会引起任何问题,或者是吗?
system.module.ts:
@NgModule({
declarations: [
ListeSystemComponent,
ListeMonitorComponent,
DatenMonitordatenComponent,
MesswertverlaufComponent,
],
imports: [
NativeScriptRouterModule,
SystemRoutingModule,
NativeScriptCommonModule,
SharedModule
],
schemas: [NO_ERRORS_SCHEMA]
})
export class SystemModule {}
简短解释代码的用途,所以也许你可以提供一些进一步的改进建议,因为我对这一切都很陌生。
登录后,用户应该被重定向到选择要显示的系统,如果他登录,他应该被重定向到他所在的系统。
--> 第一个问题:延迟加载监视器是否有意义(这就是系统中的内容)还是延迟加载监视器之后的部件更有意义?我希望你能得到我的问题^^'
当不使用子路由时,我有这样的代码:
this.router.navigate(['/system/monitorliste'], { transition: {name: 'slideLeft'}});
现在当使用子路由时,我尝试了这个:
this.router.navigate(['/monitorliste'], { transition: {name: 'slideLeft'}, relativeTo: this.route});
但它没有按预期工作......
编辑:
system-routing.module.ts:
const routes: Routes = [
{
path: "",
component: ListeSystemComponent,
children: [
{ 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 {}
我不知道如何让它工作,因为目前要么我收到错误,要么'monitorlist'
找不到 URL,要么我在选择系统时卡住了。
我想在您尝试帮助我时,您方面会有更多问题,我会尽快回答。
提前非常感谢!