我制作了一个如此处所述的Angular2 应用程序。它有两个组件(A,B),由全局导入app.module
。我的想法是,在 中包含共享模块app.module
,所以我不需要用冗余代码来搞乱每个模块。例如,我想用FormsModule
. 所以在app.module
我有
imports: [
UniversalModule,
CommonModule,
FormsModule,
AModule
RouterModule.forRoot([])
],
exports: [FormsModule]
但是在 A 模块中,我得到了Can't bind to 'ngModel' since it isn't a known property of 'select'.
似乎是由于缺少FormsModule
. 只有当我FormsModule
也使用imports: [FormsModule]
. 这正是我想要避免的。
根据这个问题,我尝试AppModule
在子模块A中导入。这不起作用并给我异常Exception: Call to Node module failed with error: Error: Unexpected value 'undefined' imported by the module 'AModule'
如何将导入继承到子模块?我也需要这个来做管道。