2017-02-06 102 views
1

我可以在本地運行。僅在生產版本中獲取錯誤。如下所示無法綁定到'ngIf',因爲它不是生產版本中的'div'的已知屬性

我已經使用

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

完整的錯誤。

client:101 Template parse errors:enter code here`Can't bind to 'ngIf' since it isn't a known property of 'div'. 
("move" class="transport-remove">Remove</a></div> 
     <div id="carTypeDiv_1" class="veh-inv-out" [ERROR ->]*ngIf="vehicleData.vesselType == 'road'"> 
      <ul id="carTypeList_1" class="veh-slides"> 
    "): [email protected]10:52 
Property binding ngIf not used by any directive on an embedded template. Make sure that the property name is spelled correctly and all directives are listed in the "@NgModule.declarations". ("t:" (click)="removeField($event)" title="Remove" class="transport-remove">Remove</a></div> 
     [ERROR ->]<div id="carTypeDiv_1" class="veh-inv-out" *ngIf="vehicleData.vesselType == 'road'"> 
      <ul "): [email protected]:9 
Can't bind to 'ngForOf' since it isn't a known property of 'option'. ("l)]="vehicleData.makeSelect" (change)="appendModel($event.target.value)"> 
        <option [ERROR ->]*ngFor="let make of vehicle.makes">{{make}}</option> 
       </select> 
      </div> 
"): [email protected]:26 
Property binding ngForOf not used by any directive on an embedded template. Make sure that the property name is spelled correctly and all directives are listed in the "@NgModule.declarations". ("[(ngModel)]="vehicleData.makeSelect" (change)="appendModel($event.target.value)"> 
        [ERROR ->]<option *ngFor="let make of vehicle.makes">{{make}}</option> 
       </select> 
      </d"): [email protected]:18 
Can't bind to 'ngForOf' since it isn't a known property of 'option'. ("t" id="modelSelect" [(ngModel)]="vehicleData.modelSelect" class="prefixbox"> 
       <option [ERROR ->]*ngFor="let model of vehicle.models">{{model}}</option> 
      </select></div> 
      <br c"): [email protected]:23 
Property binding ngForOf not used by any directive on an embedded template. Make sure that the property name is spelled correctly and all directives are listed in the "@NgModule.declarations". ("delSelect" id="modelSelect" [(ngModel)]="vehicleData.modelSelect" class="prefixbox"> 
       [ERROR ->]<option *ngFor="let model of vehicle.models">{{model}}</option> 
      </select></div> 
     "): [email protected]:15 
Can't bind to 'ngForOf' since it isn't a known property of 'option'. ("refixbox"> 
         <option value="">SELECT</option> 
         <option [ERROR ->]*ngFor="let year of vehicle.years">{{year}}</option> 
        </select> 
       "): [email protected]:32 
Property binding ngForOf not used by any directive on an embedded template. Make sure that the property name is spelled correctly and all directives are listed in the "@NgModule.declarations". ("class="prefixbox"> 
         <option value="">SELECT</option> 
         [ERROR ->]<option *ngFor="let year of vehicle.years">{{year}}</option> 
        </select> 
     "): [email protected]:24 
Can't bind to 'ngForOf' since it isn't a known property of 'option'. ("ateSelect" [(ngModel)]="vehicleData.stateSelect" class="prefixbox"> 
         <option [ERROR ->]*ngFor="let state of vehicle.regStates">{{state}}</option> 
        </select> 
      "): [email protected]:32 
Property binding ngForOf not used by any directive on an embedded template. Make sure that the property name is spelled correctly and all directives are listed in the "@NgModule.declarations". ("" id="stateSelect" [(ngModel)]="vehicleData.stateSelect" class="prefixbox"> 
         [ERROR ->]<option *ngFor="let state of vehicle.regStates">{{state}}</option> 
        </select> 
    "): [email protected]:24 
Can't bind to 'ngForOf' since it isn't a known property of 'option'. ("lorSelect" [(ngModel)]="vehicleData.colorSelect" class="prefixbox"> 
         <option [ERROR ->]*ngFor="let color of vehicle.colors">{{color}}</option> 
        </select> 
       "): [email protected]:32 
Property binding ngForOf not used by any directive on an embedded template. Make sure that the property name is spelled correctly and all directives are listed in the "@NgModule.declarations". ("" id="colorSelect" [(ngModel)]="vehicleData.colorSelect" class="prefixbox"> 
         [ERROR ->]<option *ngFor="let color of vehicle.colors">{{color}}</option> 
        </select> 
     "): [email protected]:24 

是什麼原因。我已驗證了許多解決方案。找不到靈魂。相同的代碼與本地工作正常。

+1

加入,你必須使用ngIf div元素 – mayur

回答

8

添加瀏覽器模塊後工作正常。

import { BrowserModule } from '@angular/platform-browser'; 
@NgModule({ 
    imports: [BrowserModule ] 
    }) 
+0

它真的象角的錯誤處理可能「知道」(或猜測),其ngIf是它自己的指令之一,和「知道」,它在你的HTML模板代碼在BrowserModule中。瀏覽器控制檯中的錯誤消息可能暗示'您是否導入了BrowserModule'?恐怕在Angular恕我直言中最大的缺點是錯誤信息在事情出錯時可能不太有用。 – user2748659

相關問題