-1

i have to get the value of wave1 and wave2 from array by using underscore.js

array =[{"id":1,"name":"Monoprix", "pdv":16,"graph":[{"wave1":22,"wave2":11}]} ;

i try

 $scope.wave1 =array.graph.wave1 ;
   console.log($scope.wave1) ;

console log = Unidentified

can you help me !

kenza
  • 195
  • 1
  • 4
  • 16
  • 1
    this should help http://stackoverflow.com/questions/11922383/access-process-nested-objects-arrays-or-json – Dhiraj Apr 08 '15 at 16:33
  • 1
    `array` is an array. It doesn't have a `graph` property. Its first element does, however. – gen_Eric Apr 08 '15 at 16:33

1 Answers1

0

your code is wrong, you miss ] after element list.

your array :

var array =[{"id":1,"name":"Monoprix", "pdv":16,"graph":[{"wave1":22,"wave2":11}]}];

and to get some data you must first select array index, like this:

array[0].graph