Can't bind to 'ngIf' since it isn't a known property of 'div' [duplicate]

匿名 (未验证) 提交于 2019-12-03 01:47:02

问题:

This question already has an answer here:

Can't bind to 'ngIf' since it isn't a known property of 'div'.

The element is

回答1:

If you are using RC5 then import this:

import { CommonModule } from '@angular/common';   import { BrowserModule } from '@angular/platform-browser'; 

and be sure to import CommonModule from the module that is providing your component.

 @NgModule({     imports: [CommonModule],     declarations: [MyComponent]   ... }) class MyComponentModule {} 


回答2:

Just for anyone who is missing it, I also had an issue where I typed ngif rather than ngIf (notice the capitol 'I').



回答3:

Instead of [ngIf] you should use *ngIf like this:



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!