select select - 2 months ago 24
TypeScript Question

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

Answer

I think you need to also export the module if you want it to be provided to importers

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