簡體   English   中英

Angularjs 動態 ng-if 數據綁定跨度

[英]Angularjs dynamic ng-if data binding in span

在我看來,我有這個 Angular 表達式:

 <span ng-if="{{list.StoreList ? (list.StoreList.length ' Products)' : '(0 Products)'}}"> </span>

因此,如果我在 StoreList 中有任何項目,那么我將顯示計數,否則我將只顯示 0 個產品。

我收到來自 Angularjs 的意外預期錯誤。

我該如何解決這個問題?

這格式不正確

<span ng-if="{{list.StoreList ? (list.StoreList.length ' Products)' : '(0 Products)'}}"> </span>

應該是

<span ng-if="{{ list.StoreList ? '(' + list.StoreList.length + ' Products)' : '(0 Products)'}}"> </span>

嘗試:

<span ng-if="list.StoreList">{{'(' + list.StoreList.length + ' Products)'}}</span>
<span ng-if="!list.StoreList">(0 Products)</span>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM