我试图从对象数组中获取id,但是$scope.data.id
未定义任何错误或更好的angularjs方法从数组对象获取数据?
数据
[{"_id":"57e540ab352e81329c984aba","name":"test diagram","owner":"wp6307","diagram":"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<definitions xmlns=\"http://www.omg.org/spec/BPMN/20100524/MODEL\"\r\n"}]
ctrl.js
diagramService.getDiagrams()
.then(function (resp) {
$scope.data = resp.data;
console.log(JSON.stringify($scope.data));
console.log($scope.data[0]._id); }
答案 0 :(得分:0)
PLZ尝试$ scope.data [0] [“_ id”]而不是$ scope.data [0] ._ id