NG0303: Can't bind to 'ngIf' since it isn't a known property of 'p'. code example

Example 1: Can't bind to 'ngForOf' since it isn't a known property of 'div'.

// older Angular versions
// import {BrowserModule, CommonModule} from '@angular/common';

import { BrowserModule } from '@angular/platform-browser'
..
..
@NgModule({
  imports: [BrowserModule, /* or CommonModule */],
  ..
})

Example 2: core.js:7813 Can't bind to 'ngIf' since it isn't a known property of 'div'

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

Example 3: core.js:7813 Can't bind to 'ngIf' since it isn't a known property of 'div'

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

Tags:

Misc Example