0

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:

<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 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.

2
  • How do 'user select some value'? By checking the checkbox? Commented May 27, 2016 at 5:32
  • Please go to plunkr code.There are some more drop down.You can select there. Commented May 27, 2016 at 5:40

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

1 Comment

@satya Just paste it to your controller where you have getValue function. Here you go: plnkr.co/edit/LXl01lnROyjLZXUtRllx?p=preview
0

You need to Add getValue function in your controller.

 var self = this;
 self.getValue = function(){
    $scope.isDisabled = function(dayIdx, answerIdx) {
       console.log('isDisabled', $scope.selectedAnswers[dayIdx].chkbox);
       return (!$scope.answerIsSelected(dayIdx, answerIdx) 
                  &&  $scope.selectedAnswers[dayIdx].chkbox.length === 2);
    };
 };

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.