Can't bind to 'ngIf' since it isn't a known property of 'div' in production build

前端 未结 5 1171
离开以前
离开以前 2021-01-13 03:11

I can able to run through locally. Getting error only in production build.

I have used

 import { CommonModule } from \'@angular/common\';
 imports:           


        
5条回答
  •  清歌不尽
    2021-01-13 03:35

    This error can also occur if your component is NOT included in the declarations section of the module:

    import { NgModule } from '@angular/core';
    import { CommonModule } from '@angular/common';            // <-- required
    
    import { InventoryRoutingModule } from './inventory-routing.module';
    import { InventoryComponent } from './pages/inventory/inventory.component';
    
    @NgModule({
      declarations: [InventoryComponent],                      // <-- In my case, this was missing
      imports: [CommonModule, InventoryRoutingModule]
    })
    export class InventoryModule {}
    

提交回复
热议问题