I am using AngularJS in my current project and I am trying to implement a feature which detects if cookies are disabled in browser. I have tried to use the AngularJS module "ngCookies" to resolve this issue. The main idea of this feature is to create some cookie, and later check if this cookie was created (and it is available) and show message if it wasn't. But it didn't worked.
Controller:
someProject.controller('CookieCtrl', ['$scope', '$cookieStore', function($scope, $cookieStore) {
$scope.areCookiesEnabled = false;
$cookieStore.put("TestCookie", "TestCookieText");
$scope.cookieValue = $cookieStore.get("TestCookie");
if ($scope.cookieValue) {
$cookieStore.remove("TestCookie");
$scope.areCookiesEnabled = true;
}
}]);
View:
<div class="main" data-ng-controller="CookieCtrl">
<div class="warning_message" data-ng-show="!areCookiesEnabled">
<span data-ng-bind="areCookiesEnabled"></span>
</div>
</div>
Can anybody tell me where is my mistake?