angularjs - Access Array inside Array $scope Children inside Parent Database ( NODE Angular MongoDB Javascript ) -


i running codes in node app:

controller

shirts.get({ shirtid: $stateparams.shirtid, cat: $stateparams.cat },function(response){         $scope.beta = response; }); 

view

<ul>     <li ng-repeat="sh in beta">     <input type="text" data-ng-model="sh.category[0]._id" id="name" >     <input type="text" data-ng-model="sh.category[0].name" id="name"> </ul> 

the previous code working fine

response:

556ab2a4789bf9769ea813e3

aa

but when change following not work

controller

shirts.get({ shirtid: $stateparams.shirtid, cat: $stateparams.cat },function(response){             $scope.beta = response.category[0]; }); 

view

<ul>     <li ng-repeat="sh in beta">     <input type="text" data-ng-model="sh.name" id="name" >     <input type="text" data-ng-model="sh._id" id="name" > </ul> 

error says : cannot read property '0' of undefined

it seems cannot find category have category. here have in console ( same response controller ):

{ _id: 556ab2a4789bf9769ea813e0, category: [ { name: 'aa', _id: 556ab2a4789bf9769ea813e3, picture: [] } ] } 

how can access array inside array in $scope?

thanks


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -