如果在檢查我的json
中的庫存數量時顯示正確in-stock (store) or (online)
消息的問題。如何正確檢查ng中的條件是否使用操作員檢查Angular2中的項目數量
所以情況是,如果庫存不足10
其視爲low-stock
如果如果大於10
然後in-stock
其0
然後out-of-stock
。
我的問題是當股價低於10
我*ngIf
認爲價值0
以及因此它顯示low-stock
以及out-of-stock
,或者如果股票10
它顯示low-stock
和in-stock
。但如果股票大於10
其罰款。
如何正確檢查股票以顯示正確的股票消息?
樣品JSON -
this.checkStock = {
"online": 0,
"store": 10
}
模板與ngIf
checks--
<p>
<span *ngIf="checkStock.online >= 10 "><i class="fa fa-check-circle fa-2x text-success" aria-hidden="true"></i> In-stock (Online)</span>
<span *ngIf="checkStock.online <= 10 "><i class="fa fa-exclamation-circle fa-2x text-warning" aria-hidden="true"></i> Low stock (Online)</span>
<span *ngIf="checkStock.online == 0"><i class="fa fa-times-circle fa-2x text-danger" aria-hidden="true"></i> Out-of-stock (Online)</span>
</p>
<p>
<span *ngIf="checkStock.store >= 10 "><i class="fa fa-check-circle fa-2x text-success" aria-hidden="true"></i> In-stock (store)</span>
<span *ngIf="checkStock.store <= 10 "><i class="fa fa-exclamation-circle fa-2x text-warning" aria-hidden="true"></i> Low stock (store)</span>
<span *ngIf="checkStock.store == 0"><i class="fa fa-times-circle fa-2x text-danger" aria-hidden="true"></i> Out-of-stock (store)</span>
</p>