简体   繁体   中英

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}} The page shows no results. Also if I remove | number | number It displays number as [1292] But I want it to display in 1,292 format. How can I make this work?

If it displays as [1292] , that means that places.places is not a number. It's an array containing a single element. So you need 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM