我的路由配置如下,当我在它加载的主要组件中添加LandingModuleComponent时,但是如果我包含不同的模块则不行。
const routes: Routes = [
{ path: '', redirectTo: '/landing', pathMatch: 'full' },
{ path: 'landing', component: LandingModuleComponent },
{ path: 'items', component: ItemsComponent },
{ path: 'item/:id', component: ItemDetailComponent }
];
我的LandingModuleComponent和LandingModule看起来像
@NgModule({
imports: [CommonModule],
declarations: [LandingModuleComponent],
exports: [LandingModuleComponent]
})
export class LandingModuleModule {}
@Component({
selector: 'app-landing-module',
moduleId: module.id,
templateUrl: './landing-module.component.html',
styleUrls: ['landing-module.component.css']
})
export class LandingModuleComponent implements OnInit {}
主appModule看起来像
@NgModule({
bootstrap: [AppComponent],
imports: [NativeScriptModule, AppRoutingModule, LandingModuleModule]
declarations: [AppComponent, ItemsComponent, ItemDetailComponent],
providers: [ItemService],
schemas: [NO_ERRORS_SCHEMA]
})
export class AppModule {}