lundi 25 janvier 2016

Checkbox, if checked once, should stay checked on page reload.

So, what I am trying to do is to make a few checkboxes on a page. The idea is that if I check a checkbox and then save the info in Mongo db, then reload the page, then the checkbox I checked earlier should stay checked on reload.

Let me make this Plnkr

If the plnk doesnt load, Let me enter the code as well.

<!DOCTYPE html>
<html ng-app="app">

  <head>
    <script src="http://ift.tt/1KzkEvZ" data-semver="2.0.0-alpha.45" data-require="angular.js@*"></script>
    <script src="app.js" data-semver="2.0.0-alpha.45" data-require="angular.js@*"></script>
    <link rel="stylesheet" href="style.css" />
    <script src="http://ift.tt/1Pv8BqU"></script>
    <script src="script.js"></script>
  </head>

  <body ng-controller="main">
    <label>Test checkbox</label>
    <input type="checkbox" id="" ng-model="test.checkbox" value="test" name="testCheckbox" ng-checked="">
    <br />{{ greeting }}

  </body>

</html>

Please check and let me know a solution, guys!

TIA.




Aucun commentaire:

Enregistrer un commentaire