4
我有一个代码<div class="flex-container" *ngIf="mail"> Some data </div>
如何使ngIf指令在全部项目中全局可见?
,我有一个错误Can't bind to 'ngIf' since it isn't a known property of 'div'.
我怎样才能解决这个问题?
我有一个代码<div class="flex-container" *ngIf="mail"> Some data </div>
如何使ngIf指令在全部项目中全局可见?
,我有一个错误Can't bind to 'ngIf' since it isn't a known property of 'div'.
我怎样才能解决这个问题?
导入BrowserModule
在根模块和CommonModule
在其他模块,你想使用通用指令。
@NgModule({
imports: [BrowserModule],
...
})
class AppModule {}
和
@NgModule({
imports: [CommonModule],
// Now MyComponent has access to ngIf
declarations: [MyComponent]
...
})
class OtherModule {}
BrowserModule
出口CommonModule
,这样就没有必要根模块中直接导入CommonModule
。