无法绑定到“ ngIf”,因为它不是“ table”的已知属性

时间:2020-07-30 10:24:38

标签: angular entity-framework

我尝试了这里给出的许多解决方案,但是没有用。请帮助。 我的component.ts工作正常,正在获取值,控制台上没有错误,但html页面上没有任何显示。

附加html代码图片,也将其写下来

<!--<app-customer-layout></app-customer-layout>-->
<div class="myContent">
  <h4>You have added the following products to the cart.</h4>
  <br />
  <div class="table-responsive">
    <table class="table" style="border:2px solid rgba(220,230,242,1);" *ngIf="products">
      <tr style="background-color:rgba(220,230,242,1); font-size:12pt">
        <th>Product Name</th>
        <th>Price</th>
        <th>Quantity</th>
        <th>Total Amount</th>
        <th style="text-align:center" colspan="2">Action(s)</th>
      </tr>
      <tr *ngFor="let product of products" style="background-color:white">
        <td>{{product.ProductName}}</td>
        <td>{{product.Price}}</td>
        <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{{product.Quantity }}&nbsp;</td>
        <td>{{product.Price * product.Quantity}}</td>
        <<!--td style="text-align:right"><button title="Update Quantity" (click)="updateCart(product)" class="btn">Update Quantity</button></td>
        <td><img title="Remove from cart" [src]="imageSrc" (click)="removeProductFromCart(product)"></td>-->
      </tr>
    </table>
    <div *ngIf="showError" style="">
      <h4 class="jumbotron" style="text-align:center;">{{errorMsg}}</h4>
    </div>
  </div>
</div>

] 1

1 个答案:

答案 0 :(得分:0)

NgIfCommonModule提供。请确保CommonModule已导入组件所在的模块中。

import {CommonModule} from '@angular/common';

@NgModule({
    imports: [
        CommonModule
    ]
})