【发布时间】:2017-02-06 08:28:52
【问题描述】:
我有一个代码<div class="flex-container" *ngIf="mail"> Some data </div>
我有一个错误Can't bind to 'ngIf' since it isn't a known property of 'div'.
我该如何解决?
【问题讨论】:
标签: angular typescript frontend angularjs-ng-if
我有一个代码<div class="flex-container" *ngIf="mail"> Some data </div>
我有一个错误Can't bind to 'ngIf' since it isn't a known property of 'div'.
我该如何解决?
【问题讨论】:
标签: angular typescript frontend angularjs-ng-if
在根模块中导入BrowserModule,在您想使用通用指令的其他模块中导入CommonModule。
@NgModule({
imports: [BrowserModule],
...
})
class AppModule {}
和
@NgModule({
imports: [CommonModule],
// Now MyComponent has access to ngIf
declarations: [MyComponent]
...
})
class OtherModule {}
BrowserModule导出CommonModule,这样就不需要在根模块中直接导入CommonModule了。
【讨论】: