我是angularjs的新手,我正在尝试从json文件中检索json数据。但是我无法做到。
这是我在控制器中的方法:
.controller('firstCtrl', ['$scope', '$http', function ($scope, $http) {
$http.get('https://feeds.citibikenyc.com/stations/stations.json').
success(function (data, status, headers, config) {
$scope.data = data;
alert(data);
}).
error(function (data, status, headers, config) {
// called asynchronously if an error occurs
// or server returns response with an error status.
});
}]);
我想将特定值保存到范围中。我怎样才能做到这一点?在警告中显示:[object Object]。
如何访问此json文件中的每个值?
感谢。
答案 0 :(得分:0)
var list = data.stationBeanList;
var listId = list.map( function (object) {
return object.id;
});
通过这种方式,您可以将所有身份证放在一个数组listId