dimanche 23 juillet 2017

Set current checkbox value in "$on('$destroy')" in angular js?

I am new in angular js. I am implementing checkbox and also I want to prevent reset checkbox after reloading and after navigate to another page. Right now when I reloading the page then checkbox will reset. So I am using $on("$destroy") saving the state. But I am not able to set checkbox current value with $on("$destroy").

HTML

<input type="checkbox" id="mycheckbox" class="checkbox style-0" name="mycheckbox" ng-model="mycheckbox" data-ng-change="confirm()" />

ANGULAR CONTROLLER:

$scope.confirm= function(){
  if($scope.mycheckbox== false)
  {
    alert("inside unchecked");
  }

  else{
    alert("inside checked");
  }
}
$scope.$on('$destroy',function(){ 
  sessionStorage.date=matchDate;
  sessionStorage.maxValue=realValue;
  sessionStorage.minValue=normalValue;
})

How to set current checkbox value checked or unchecked in $on(destroy). I am already set some value in $on(destroy), But in checkbox case I am confused. So please share your idea. Your answer valuable for me.Thanks in advance.




Aucun commentaire:

Enregistrer un commentaire