我有一个返回数量的数组。
<h3 ng-controller="TotalPlacesCtrl">Total Places: {{places.places}}</h3>
每当我添加{{places.places | number}}
时
该页面显示无结果。
此外,如果我删除| number
它显示数字为[1292]但我希望它以1,292格式显示。
我怎样才能做到这一点?
答案 0 :(得分:1)
如果显示为[1292]
,则表示places.places
不是数字。它是一个包含单个元素的数组。所以你需要places.places[0]
。
答案 1 :(得分:0)
尝试:
{{places.places[0] | number}}
对我来说这是一个数组而你正在重新整理整个数组而不是引用它的索引。