简体   繁体   中英

angular2 use component of nested imported module

is it possible to have the following strucure?

app.component.js

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

app.module.js

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

core.module.js

@NgModule({
    imports: [NavModule]
class CoreModule

nav.module.js

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

nav-context.component.js

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

So far I get '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]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM