Join the Stack Overflow Community
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

I am trying to get id from array of object but $scope.data.id is coming undefined any idea what is implemented wrong or any better angularjs way to get data from array object ?

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); }
share|improve this question
    
Shouldn it be $scope.data[0]["_id"] ? – Gustavo Gabriel 19 hours ago

Plz try $scope.data[0]["_id"] instead of $scope.data[0]._id

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.