私は角度1.4から構造の一部を移植したいと思っています...角2:輸入の誤解
そして私はいくつかの問題があります。 - モジュールは、顧客はモジュール、リストされている - モジュールがある
コンポーネント:たとえば、私は、このような構造を有しています。
モジュール&のインポートに問題があります。
私は、このような方法でそれを実行します。
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>
を、私はここにangular2ブートストラップを使用する場合:
<ngb-accordion #acc="ngbAccordion" activeIds="ngb-panel-0">
<ngb-panel title="Simple">
<template ngbPanelContent>
demo
</template>
</ngb-panel>
</ngb-accordion>
すべては問題ありません。
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>
そして、ここでは、私はエラーを取得:
zone.js:388Unhandled Promise rejection: Template parse errors: 'ngb-panel' is not a known element:
しかし、私はapp.module達するまで、私は、すべてのモジュールでNgbModule
をインポートする場合 - すべてがうまくあります。しかし、これはばかげている。
角度2のモジュールのインポートを整理する可能性はありますか?ルートにインポートされたすべてのモジュールでインポートする必要はありません。ネストしたモジュールで再利用できます角度1.4(ngInjectを使用)?
'ListModule'の中でのみ' NgbModule'を使用する場合は、そこにインポートする必要があります。あなたはそれを持っている:)おそらく長いショット、しかし、余分なスペースは、 ''問題がありますか? –
PierreDuc
@PierreDuc は役に立ちません( – brabertaser19