[英]Angular number filter in HTML not working; empty string is returned
I have an array returning number of places. 我有一个数组返回的地方。
<h3 ng-controller="TotalPlacesCtrl">Total Places: {{places.places}}</h3>
Whenever I add {{places.places | number}}
每当我添加
{{places.places | number}}
{{places.places | number}}
The page shows no results. {{places.places | number}}
页上没有显示结果。 Also if I remove | number
另外,如果我删除
| number
| number
It displays number as [1292] But I want it to display in 1,292 format. | number
它显示为[1292],但我希望它以1,292格式显示。 How can I make this work? 我该如何进行这项工作?
If it displays as [1292]
, that means that places.places
is not a number. 如果显示为
[1292]
,则意味着places.places
不是数字。 It's an array containing a single element. 它是一个包含单个元素的数组。 So you need
places.places[0]
. 因此,您需要
places.places[0]
。
Try with: 尝试:
{{places.places[0] | number}}
Seems to me that is an array and you are refrencing the whole array instead do refer with its index. 在我看来,这是一个数组,您要遍历整个数组,而不要引用其索引。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.