Unexpected token <= at column 26 in [product.quantity > 50 or <=200] in /~/src/app/Components/products/products.component.html@30:18
实际上我是angular应用程序的新手…当我尝试多个ngIf指令使用获取时,如果数量小于或等于50,则会发生上述错误,"降低库存水平"。如果数量大于50且小于或等于200,则为"平均库存水平",如果数量大于200,则为"足够库存水平"。
<div class="container-fluid main-content">
<div class="row">
<section class= "col-md-12">
<div class="mt-3 mb-3">
<h3>Product List</h3>
</div>
<table class="table">
<thead class="thead-light t-head">
<tr>
<th scope="col">Product Id</th>
<th scope="col">Product Name</th>
<th scope="col">Product Description</th>
<th scope="col">Created Date</th>
<th scope="col">Unit Price</th>
<th scope="col">Quantity in Kgs</th>
<th scope="col">Availability</th>
<th scope="col">Product Actions</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let product of products">
<th scope="row">{{product.productId}}</th>
<td>{{product.productName}}</td>
<td>{{product.productDescription}}</td>
<td>{{product.createdDate}}</td>
<td>{{product.unitPrice}}</td>
<td>{{product.quantity}}</td>
<td>
<p *ngIf="product.quantity <= 50"> Lower Inventory </p>
<p *ngIf="product.quantity > 200">Sufficent Inventory</p>
<p *ngIf="product.quantity > 50 or <=200">Average Inventory Level</p>
</td>
<td>
<i class="fa fa-eye icon"></i>
<i class="fa fa-pencil-square-o icon"></i>
</td>
</tr>
</tbody>
</table>
</section>
</div>
</div>
在or/and之后,您必须指定要检查的变量。在您的情况下,您必须在or
product.quantity
正如@Robby Cornelissen评论的那样,代码应该是这样的:
product.quantity > 50 || product.quantity <=200