无法绑定到"ngIf",因为它不是生产版本中"div"的已知属性 [英] Can't bind to 'ngIf' since it isn't a known property of 'div' in production build

查看:78
本文介绍了无法绑定到"ngIf",因为它不是生产版本中"div"的已知属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以在本地运行.仅在生产版本中出现错误.

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

我用过

 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">
    "): VehicleDirective@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 "): VehicleDirective@10: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>
"): VehicleDirective@28: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"): VehicleDirective@28: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"): VehicleDirective@36: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>
         "): VehicleDirective@36: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>
                 "): VehicleDirective@47: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>
         "): VehicleDirective@47: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>
           "): VehicleDirective@55: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>
   "): VehicleDirective@55: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>
              "): VehicleDirective@68: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>
      "): VehicleDirective@68:24

是什么原因.我已经验证了许多解决方案.找不到灵魂.相同的代码可以在本地正常工作.

What is the reason. I have verified many solution. could not find the soultion. Same code is working fine with local.

推荐答案

添加浏览器模块后,其工作正常.

After adding browser module its working fine.

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

这篇关于无法绑定到"ngIf",因为它不是生产版本中"div"的已知属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆