This question already has an answer here:
Can't bind to 'ngIf' since it isn't a known property of 'div'.
The element is If you are using RC5 then import this: and be sure to import Just for anyone who is missing it, I also had an issue where I typed Instead of [ngIf] you should use *ngIf like this:回答1:
import { CommonModule } from '@angular/common'; import { BrowserModule } from '@angular/platform-browser';
CommonModule
from the module that is providing your component. @NgModule({ imports: [CommonModule], declarations: [MyComponent] ... }) class MyComponentModule {}
回答2:
ngif
rather than ngIf
(notice the capitol 'I').回答3: