I want dynamic ng-model in ng-repeat and want to get value of these ng-models in controller. I searched it on google and used this solution of stackoverflow. But it's giving me undefined in my case.I don't know why so.
My HTML code is
<div class="item" ng-repeat="question in quiz_questions">
<p ng-bind-html="question.question"></p>
<div class="dh_yabox">
<div class="placeholder">Your Answer:</div>
<input ng-model="answers[question.question]" class="ansf" type="text" />
</div>
</div>
<div ng-click="nextQuestion()" class="pay_btn btn_defa"><a class="next">Next Question</a></div>
Controller code is
$scope.nextQuestion = function(){
console.log($scope.answers);
angular.element('.slick-next').triggerHandler('click');
}
and in quiz_questions following is the data
[{"qid":"3","question":"<p>First Quiz Q2</p>\r\n\r\n<p><img alt=\"\" src=\"http://localhost/project/backend/uploads/qt-01.png\" style=\"width: 520px; height: 390px;\" /></p>\r\n","quiz_id":"6","answer":"test,question","time":"2016-09-22 12:43:28","quiz_name":"free quiz","id":"6"},{"qid":"1","question":"First Quiz Q1","quiz_id":"6","answer":"test,test1,test2","time":"0000-00-00 00:00:00","quiz_name":"free quiz","id":"6"}]
Can any body please tell me what am I doing wrong here?