Angularjs Set and Remove Cookies

Angularjs Set and Remove Cookies


I want to store some values in cookie.  So i used angular-cookies-min script for add some values to cookies I have used this below code for save values to cookie. Notify Toaster

Angularjs Set and Remove Cookies
Angularjs Set and Remove Cookies

Set Cookie

 $cookieStore.put("mychooise", mychooise);
put(key, value, [options]);

Delete Cookie

$cookieStore.remove("mychooise");
angular.forEach($cookies, function(a, b) {
    $cookieStore.remove(k);
});
getAll()

var cookies = $cookies.getAll();
angular.forEach(cookies, function(a, b) {
    $cookies.remove(k);
});

.controller('SignoutCtrl',['$scope','$cookies',toaster,function($scope,$cookies,toaster){
    $cookies.mychooise= undefined;
});


angular.module('SignoutCtrl', ['ngCookies'])
.controller('ExampleController', ['$cookies', function($cookies) {
  // Retrieving a cookie
  var favoriteCookie = $cookies.get('mychooise');
  // Setting a cookie
  $cookies.put('mychooise', 'mychooise');
}]);
Angularjs Set and Remove Cookies Dev2Tricks 5 of 5
Angularjs Set and Remove Cookies I want to store some values in cookie.  So i used angular-cookies-min script for add some values to co...

Share this

Related Posts

Previous
Next Post »

Xolo Offer