【发布时间】:2014-11-20 10:05:38
【问题描述】:
在 $http 获取请求资源 api 后返回多行 json:(示例)
{"features":["type": "feature", "properties":{ "id": "001", "name": "Example"}]}
如何从该数据中获取 id?
$scope.myDate = $http.get('http://example.com/').
success(function(data, status){
var test = data.features;
$scope.information = test['type'];
}).
error(function(data, status){
console.log('not');
});
我使用的方式不正确,有什么建议吗? 提前谢谢你!
【问题讨论】:
-
这个 json 似乎无效, features 是一个数组,并且包含键值。应该是一个对象