[英]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"]
嗨,我在WordPress网站上使用AngularJS,并且在我的局部HTML文件(例如
{{post.manualest}}
使用Angular标签显示自定义字段值时,它显示为["1,500,000"]
How can I remove [" "]
so that it shows only 1,500,000
? 如何删除
[" "]
,使其仅显示1,500,000
?
Since {{post.manualest}}
contains an array you need ng-repeat
由于
{{post.manualest}}
包含一个数组,因此需要ng-repeat
<p ng-repeat="tag in post.manualest">{{tag}}</p>
The ngRepeat directive instantiates a template once per item from a collection.
ngRepeat指令对集合中的每个项目实例化一次模板。 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.每个模板实例都有其自己的作用域,其中给定的循环变量设置为当前集合项,
$index
设置为项索引或键。
https://docs.angularjs.org/api/ng/directive/ngRepeat https://docs.angularjs.org/api/ng/directive/ngRepeat
The data you received (in manualest
key) is an Array. 您收到的数据(使用
manualest
键)是一个数组。 So either you can use the ng-repeat
as @Vicky suggested or you can simply write in your HTML: 因此,您可以按照@Vicky的建议使用
ng-repeat
,也可以直接在HTML中编写:
{{post.manualest[0]}}
Edit : Like @FuzzyTree already mentioned in the comment. 编辑 :喜欢@FuzzyTree已经在评论中提到。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.