2017-02-06 56 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]: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

あなたは – mayur

答えて

8

ブラウザモジュールを追加した後、正常に動作します。

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

はそれが本当に角度のエラーハンドリングのように見える「知っている」ngIfは、それ自身のディレクティブの一つであり、その(または推測)を「知る」こと、その可能性のdiv要素にngIfを使用する必要がありあなたのHTMLテンプレートのコードを追加します。 BrowserModuleにあります。ブラウザのコンソールに表示されるエラーメッセージに、「あなたはBrowserModuleをインポートしましたか?」というメッセージが表示される可能性があります。 Angular IMHOの最大の欠点は、エラーメッセージが間違っているときに役立ちます。 – user2748659

関連する問題