var app = angular.module('plunker', []);
app.controller('MainCtrl', function($scope) {
$scope.name = 'World';
$scope.checkBoxes = [false, false, false, false];
if(localStorage['checkBoxes']){
$scope.checkBoxes = JSON.parse(localStorage.getItem("checkBoxes"));
console.log(localStorage['checkBoxes'].length);
}
$scope.valueChange =function(){
localStorage.setItem("checkBoxes", JSON.stringify($scope.checkBoxes));
};
});
<!DOCTYPE html>
<html ng-app="plunker">
<head>
<meta charset="utf-8" />
<title>AngularJS Plunker</title>
<script>document.write('<base href="' + document.location + '" />');</script>
<link rel="stylesheet" href="style.css" />
<script data-require="angular.js@1.5.x" src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.11/angular.min.js" data-semver="1.5.11"></script>
<script src="app.js"></script>
</head>
<body ng-controller="MainCtrl">
<p>Hello {{name}}!</p>
<p ng-repeat="check in checkBoxes track by $index">
<label>{{$index}}</label>
<input type="checkbox" ng-model="checkBoxes[$index]" ng-change="valueChange()"/>
</p>
<pre>{{checkBoxes}}</pre>
</body>
</html>
/* Put your css in here */