Check the box after moving from the page.

I have a checkbox that I need to save after going from the page. I am using AngularJS and bootstrap. Right now, I am returning the linked variable to false every time I reload the page (when the controller starts): how can I save the most recent variable ( $scope.disableCheck)?

In my controller ....

$scope.disableCheck = false;
$scope.removeCheck = function () {
   $scope.disableCheck = !$scope.disableCheck;
}

And in my HTML ...

<input class="notification-checkbox" type="checkbox" value="{{disableCheck}}" ng-click="removeCheck()" ng-clicked="{{disableCheck}}">
0
source share
1 answer

Try using $ rootScope instead. It is global for all controllers.

Something like that

.controller('someCtrl', function($scope, $rootScope) {
  $rootScope.disableCheck = true;//set root scope here and refer to it as needed from other controlers
})
+1
source

Source: https://habr.com/ru/post/1652362/


All Articles