简体   繁体   English

angular2使用嵌套导入模块的组件

[英]angular2 use component of nested imported module

is it possible to have the following strucure? 有没有可能有以下结构?

app.component.js app.component.js

@Component({
    template: '<nav-context></nav-context>'
class AppComponent

app.module.js app.module.js

@NgModule({
    imports: [CoreModule]
    boostrap: [AppComponent]

core.module.js core.module.js

@NgModule({
    imports: [NavModule]
class CoreModule

nav.module.js nav.module.js

@NgModule({
    declarations: [NavContextComponent]
    exports: [NavContextComponent]
class NavModule

nav-context.component.js NAV-context.component.js

@Component({
    selector: 'nav-context'
class NavContextComponent

So far I get 'nav-context' is not a known element 到目前为止,我得到的'nav-context' is not a known element

I think you need to also export the module if you want it to be provided to importers 如果您希望将模块提供给导入器,我认为您还需要导出模块

@NgModule({
    imports: [NavModule]
    exports: [NavModule]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Angular2 无法识别来自导入模块的组件 - Angular2 Not Recognizing component From Imported Module 单元测试带有导入模块的angular2组件 - Unit Testing angular2 component with imported module Angular2-导入组件时找不到模块 - Angular2 - module not being found when imported into component 如何在angular2中的子模块组件中使用父模块组件 - how to use parent module component in child module component in angular2 Angular2/nativeScript:奇怪的错误,抱怨组件未导入任何模块,即使它已导入主模块 - Angular2/nativeScript: Strange error complaining about a component that's not imported into any module even though it is imported in the main module 在core.module上导入的组件上的Angular2链接不起作用 - Angular2 link on component imported on core.module don't work Angular2:模块和组件的区别 - Angular2: Module and Component difference Angular2:行为很奇怪,即使组件未导入到app.module中,也会出现错误提示该组件未导入 - Angular2: Very strange behaviour, error complaining about a component that's not imported even though it is imported in app.module 使用导入模块中的组件 - Use component from imported module Angular:无法在来自不同模块的组件中使用在应用模块中导入的模块 - Angular: Cannot use module imported in app module in a component from a different module
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM