Skip to content

How check check-box dynamically in click event using Angular.js/JavaScript

I need to check check-box when user will click on a button the check box will selected using Angular.js. My code is below:

<input type="checkbox" name="answer_{{$index}}_check" 
   ng-checked="answerIsSelected($parent.$index, $index)" 
   ng-click="toggleAnswerSelected($parent.$index, $index)" 
   ng-disabled="isDisabled($parent.$index, $index)" 
<input type="button" value="Edit" ng-click="getValue()">

When user will click on edit button the check-box should be selected. I am providing my code in this Plunkr. You can find there is store button and edit button. When user will select some value and check-box click on store button, I need to store all value. When user will click on edit button, the stored value will set on required row check-box.


In your case it is simply:

$scope.getValue = function(){
      $scope.days.forEach(function (day) {
        day.answers.forEach(function (answer) {
          answer.check = true;