vendredi 4 décembre 2015

Maintain the previous state of checkbox on the page refres using angular js

I have a checkbox, when the checkbox is checked one div is show, on the uncheck state div is hidden, it works well, but when i checked the checkbox and refresh the page it turns into unchecked state, how can I can maintain the state of checkbox on the page refresh, Sorry for bad english, thanks in advance.

Angular code:

myApp.controller("expressionController", function ($scope) {
// Show or Hide Div

$scope.showHideDiv = function () {
if ($scope.chkStatus) {
$scope.showhideprop = true;
}
else {
$scope.showhideprop = false;
}
}
});

HTMLcode:

<form id="form1">
<div data-ng-app="sampleapp" data-ng-controller="expressionController">
Show or Hide Div: <input type="checkbox" name="tarn" ng-change="showHideDiv()" /> <br /><br />
<div style="padding:10px; border:1px solid black; width:30%; font-weight:bold" ng-show='showhideprop'>Hi Welcome to Angularjs... Hello World</div>
</div>
</form>




Aucun commentaire:

Enregistrer un commentaire