NativeScript / Angular - 无法找到加载组件的主插座

时间:2017-04-17 07:42:16

标签: angular typescript nativescript nativescript-angular

我在nativescript app中的一个延迟加载路由中使用children路由时出现问题。当我尝试访问signin或注册时,我只是收到错误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 {}

0 个答案:

没有答案