1
votes

I am using angular js. And implementing input checkbox, So this checkbox checked by default from angular controller using ng-model:

Controller:

var checkBoxVal = true;
  $scope.checkboxModel = {
    value : checkBoxVal,
  } 

$scope.call = function(){
alert("--comes--");
 if($scope.checkboxModel== false)
  {

  }
  if($scope.mycheckbox== true){

  }
}

HTML:

 <input type="checkbox" ng-model="checkboxModel.value" data-ng-change="call();"/>

But when call the function "call()" then it is not coming in if condition because $scope.checkboxModel is undefined. When I use only ng-model="checkboxModel" then it is coming in if condition with true and false. But I want to use both set true value in like ng-model="checkboxModel.value" and compare the checkbox value after calling the call() function.

1
Change like this if($scope.checkboxModel.value) - Vivz
@Vivz It is working - Varun Sharma

1 Answers

0
votes

You don't need two ng-models. Change your condition to this since you want to evaluate based on ng-models value

if($scope.checkboxModel.value)