I wanna port some of structure from angular 1.4...
And I have some troubles. For example I have such structure:
components - is a module, customer is a module, list - is a module.
I have troubles with importing modules & components.
I do it in a such way:
app.module
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { AppComponent } from './app.component';
import { MaterialModule } from '@angular/material';
import 'hammerjs';
import {NgbModule} from '@ng-bootstrap/ng-bootstrap';
import { ComponentsModule } from './components/components.module';
import { CoreModule } from './core/core.module';
import { ServicesModule } from './services/services.module';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
FormsModule,
HttpModule,
MaterialModule.forRoot(),
ComponentsModule,
CoreModule,
ServicesModule,
NgbModule.forRoot()
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
app.component.html
<customer-list></customer-list>
and if I use here angular2 bootstrap:
<ngb-accordion #acc="ngbAccordion" activeIds="ngb-panel-0">
<ngb-panel title="Simple">
<template ngbPanelContent>
demo
</template>
</ngb-panel>
</ngb-accordion>
everything is ok.
components.module
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { CustomerModule } from './customer/customer.module';
@NgModule({
imports: [
CommonModule
],
declarations: [],
exports: [CustomerModule]
})
export class ComponentsModule { }
customer.module
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { CustomerComponent } from './customer.component';
import { ListComponent } from './list/list.component';
import { ItemComponent } from './list/item/item.component';
@NgModule({
imports: [
CommonModule
],
declarations: [CustomerComponent, ListComponent, ItemComponent],
exports: [CustomerComponent, ListComponent]
})
export class CustomerModule { }
list.module
import { NgModule } from '@angular/core';
import {NgbModule} from '@ng-bootstrap/ng-bootstrap';
import { CommonModule } from '@angular/common';
import { ListComponent } from './list.component';
import { ItemComponent } from './item/item.component';
@NgModule({
imports: [
CommonModule,
NgbModule
],
declarations: [ListComponent, ItemComponent],
exports: [ListComponent]
})
export class CustomerModule { }
list.component.html
<ngb-accordion #acc="ngbAccordion">
<ngb-panel >
<template ngbPanelContent>
test
</template>
</ngb-panel>
</ngb-accordion>
And here I get error:
zone.js:388Unhandled Promise rejection: Template parse errors: 'ngb-panel' is not a known element:
But if I import NgbModule
in every module, till I reach app.module - everything is fine. But this is ridiculous.
Is there any possibility, to organize imports of modules in angular 2, so, that I don't need to import them in every module, once imported in root - I can reuse them in nested modules, like it was in angular 1.4 (using ngInject)?