簡體   English   中英

HTML中的角度數字過濾器不起作用; 返回空字符串

[英]Angular number filter in HTML not working; empty string is returned

我有一個數組返回的地方。

      <h3 ng-controller="TotalPlacesCtrl">Total Places: {{places.places}}</h3>

每當我添加{{places.places | number}} {{places.places | number}}頁上沒有顯示結果。 另外,如果我刪除| number | number它顯示為[1292],但我希望它以1,292格式顯示。 我該如何進行這項工作?

如果顯示為[1292] ,則意味着places.places不是數字。 它是一個包含單個元素的數組。 因此,您需要places.places[0]

嘗試:

{{places.places[0] | number}}

在我看來,這是一個數組,您要遍歷整個數組,而不要引用其索引。

暫無
暫無

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

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