I need help with extracting the id from an array of objects in AngularJS. It seems like $scope.data.id
is returning undefined. Can anyone spot what I may be doing wrong, or suggest a better way to achieve this?
Data:
[{"_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); }