satya satya - 6 months ago 24
AngularJS Question

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

i need one help. I need to check check-box when user will click on a button the check box will selected using Angular.js. I am explaining my code below.

<td>
<input type="checkbox" name="answer_{{$index}}_check" ng-model="answer.check" ng-checked="answerIsSelected($parent.$index, $index)" ng-click="toggleAnswerSelected($parent.$index, $index)" ng-disabled="isDisabled($parent.$index, $index)" ng-true-value="true" ng-false-value="false" style="margin-left:10px;">
</td>
<input type="button" value="Edit" ng-click="getValue()">


When user will click on
edit
button the check-box should selected.I am explaining my all code in plunkr.There you can find there is store button and edit button.I need when user will select some value and check-box click on store button all value will stored .When user will click on edit button, the stored value will set on required row check-box.My code is Here.Please help me.

Answer

In your case it is simply:

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

https://plnkr.co/edit/LXl01lnROyjLZXUtRllx?p=preview

Comments