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
Post a Comment