所以我正在使用 Angular 2 final (2.0.0),假设我创建了一个 WidgetsModule,其中包含一堆指令和组件,这些指令和组件将帮助我构建我的应用程序,然后将其导入我的 AppModule
import { NgModule } from '@angular/core';
import { UniversalModule } from 'angular2-universal';
import { WidgetsModule } from '../../../widgets';
import { App, appRouting } from './';
@NgModule({
imports: [
UniversalModule,
WidgetsModule,
appRouting
],
providers: [ AppPresenter ],
declarations: [ App ],
exports: [ ],
bootstrap: [ App ]
})
export class AppModule { }
然后我想在子模块中使用小部件,如 HomeModule、CartModule 等。如何使小部件可用而不必在每个其他模块中导入 WidgetsModule?
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule, ReactiveFormsModule } from '@angular/forms'
import { WidgetsModule } from '../../../widgets';
import { Cart, cartRouting } from './';
@NgModule({
imports: [
CommonModule,
FormsModule,
ReactiveFormsModule,
WidgetsModule, //<-- I want to avoid doing this in every module
cartRouting
],
providers: [ ],
declarations: [ Cart ]
})
export class CartModule { }
有没有办法像使用exports []中的指令一样做到这一点?