lundi 24 juin 2019

Angularjs: How to keep checkbox value after reload

I got the following code from W3Schools, but am wondering how to get the checkbox value to persist even after reload:

Keep HTML: <input type="checkbox" ng-model="myVar">

<div ng-if="myVar">
<h1>Welcome</h1>
<p>Welcome to my home.</p>
<hr>
</div>

<p>The DIV element will be removed when the checkbox is not checked.</p>
<p>The DIV element will return, if you check the checkbox.</p>

Right now, if you check the box and reload the page, the checkbox becomes unchecked again. How would you get the checkbox to retain its value even after reload? Thanks!




Aucun commentaire:

Enregistrer un commentaire