【发布时间】:2017-04-25 08:38:14
【问题描述】:
我是 AngularJS 和 JSON 的新手。我被困在这个阶段,我想过滤 JSON 中不必要的字段。
我在控制器中使用了代码:
var data = $scope.choices; // Is an array
var datav = (JSON.stringify(data)); // array converted into a string need to be filtered
alert(datav);
如果我 alert(datav) 正在获取下面提到的 JSON 数据。
[{"title":"g","$$hashKey":"object:3"},{"id":"choice2","$$hashKey":"object:6","title":"ghgh"},{"id":"choice3","$$hashKey":"object:11","title":"fgh"}]
我只想要“标题”我不想要$$hashKey 和id。如何做到这一点?
【问题讨论】:
-
使用
.map()只返回你想要的内容
标签: javascript angularjs arrays json