Get access to array inside object in javascript -


i new angularjs dont know how push value array @ particular position. example :

$scope.atparticular.push =  [  {questiontext: 'queston1',questionid: '1',answerlst:[{answertext:'answer1',answerid: 'a1'},{answertext: 'answer2',answerid: 'a2'},{answertext: 'answer3',answerid: 'a3'}]},  {questiontext: 'row2queston1',questionid: 'rq1',answerlst:[{answertext:'row2answer1',answerid: 'row2a1'},{answertext: 'row2answer2',answerid: 'row2a2'},{answertext: 'row2answer3',answerid: 'row2a3'}]}  ]; 

if object containing list , if want append answerlst 1 more position containing empty values such :

$scope.atparticular.push =      [      {questiontext: 'queston1',questionid: '1',answerlst:[{answertext:'answer1',answerid: 'a1'},{answertext: 'answer2',answerid: 'a2'},{answertext: 'answer3',answerid: 'a3'},{answertext: '',answerid: ''}]},      {questiontext: 'row2queston1',questionid: 'rq1',answerlst:[{answertext:'row2answer1',answerid: 'row2a1'},{answertext: 'row2answer2',answerid: 'row2a2'},{answertext: 'row2answer3',answerid: 'row2a3'},{answertext: '',answerid: ''}]}      ]; 

please give suggestion. in advance.

if understand correctly, want add object @ end of array answerlst of first element of array $scope.atparticular.push.

so want:

$scope.atparticular.push[0].answerlst.push({answertext: '',answerid: ''}); 

note has nothing angularjs per se. it's plain javascript.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -