0

I hava a checkbox ,the model status.useJoin also bind the div.

<input type="checkbox"  ng-model="status.useJoin"  ng-click="toggleJoin($event);" >

 <div ng-if="status.useJoin"> show area</div>

when status.useJoin is true ,will show div.

My question is ,when I want to prevent the default action of the checkbox. I will write function toggleJoin like this.

  $scope.toggleJoin = function (dimension,$event) {
   if (status.useJoin) {
      $event.preventDefault();
      return; 
   }
 }

the checkbox action is stopped ,but status.useJoin is still modified. How can I stop the bind?

1 Answer 1

1

You can use ng-disabled directive

<input type="checkbox"  ng-model="status.useJoin"  ng-disabled="onYourDisableCondition();" >


$scope. onYourDisableCondition = function () {
   if (status.useJoin) { //Add your additional conditions     
      return true; 
   }
 }
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.