@lynskey08 wrote:
Hi everyone,
I was just wondering could anyone help me with this. I want to save the state of a checkbox after leaving the page and to be able to go back into that page and have the checkbox still checked. Any ideas?//the page with the checkbox
'<'input type="checkbox" ng-model="checked"
ng-change="save(checked)"
ng-init="checked = CONFIG">//the controller of that page
.controller('chemicalEmergencyCtrl', function($scope, $http) {
$scope.newTask = function() {
$http({
method: 'GET',
url: 'http://blahblahblah.cloudapp.net/prepareMessage.php',
}).success(function(data) {
$scope.description = data;
})
.error(function(data) {
$scope.description = "No categories found by that name";
})
}$scope.CONFIG = localStorage.getItem('CONFIG'); if (!$scope.CONFIG) { $scope.CONFIG = true; } $scope.save = function(checked) { $scope.CONGIF = checked; localStorage.setItem('CONFIG', $scope.CONFIG); }
})
Posts: 1
Participants: 1