简体   繁体   中英

Remove brackets and quotations from JSON value

Hi I am using AngularJS on a WordPress site and when displaying custom field values using Angular tags in my partials HTML file such as {{post.manualest}} , it displays as ["1,500,000"]

How can I remove [" "] so that it shows only 1,500,000 ?

Since {{post.manualest}} contains an array you need ng-repeat

<p ng-repeat="tag in post.manualest">{{tag}}</p>

The ngRepeat directive instantiates a template once per item from a collection. Each template instance gets its own scope, where the given loop variable is set to the current collection item, and $index is set to the item index or key.

https://docs.angularjs.org/api/ng/directive/ngRepeat

The data you received (in manualest key) is an Array. So either you can use the ng-repeat as @Vicky suggested or you can simply write in your HTML:

{{post.manualest[0]}}

Edit : Like @FuzzyTree already mentioned in the comment.

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