我children
在 nativescript 应用程序中的一个延迟加载的路由中使用路由时遇到问题。当我尝试访问登录或注册时,我只会收到一条错误消息Cannot find primary outlet to load 'SigninComponent'
,这对我来说没有意义。
这是我的路由器模块:
const routes: Routes = [
{
path: '',
component: CompanyComponent,
children: [
{
path: 'signin',
loadChildren: 'routes/+company/routes/+signin/signin.module#SigninModule'
}
]
}
];
@NgModule({
imports: [NativeScriptRouterModule.forChild(routes)]
})
export class CompanyRouterModule {}
这是延迟加载的模块:
@NgModule({
imports: [
SharedModule,
CompanyRouterModule
],
exports: [CompanyRouterModule],
declarations: [CompanyComponent]
})
export class CompanyModule {}
最后的模板CompanyComponent
有一个出口:
<page-router-outlet></page-router-outlet>
为什么这不起作用?
编辑
这是顶级路由配置,所以signin
路由是通过/company/signin
.
const routes: Routes = [
{
path: '',
loadChildren: './routes/+home/home.module#HomeModule'
},
{
path: 'company',
loadChildren: './routes/+company/company.module#CompanyModule'
}
];
@NgModule({
imports: [
NativeScriptRouterModule,
NativeScriptRouterModule.forRoot(routes),
],
exports: [
NativeScriptRouterModule
]
})
export class AppRouterModule {}