Cookies are the information of the user, which resides in a browser of any corresponding website he/she visited.
Cookies are also the important aspects which we use to maintain session.
Here we perform some basic operation in cookie by using AngularJS.
first, to perform operations we need to call a service ngCookies.
GET operation
$cookies.get('CustomerCode')
Here we taking the value of customer code which is already saved in cookies.
Here is some implementation:
angular.module('myApp', ['ngCookies'])
.controller('myController', ['$cookies', function($cookies) {
var favoriteCookie = $cookies.get('CustomerCode');
}]);
UPDATE operation
$cookies.put('CustomerCode', 'A9m4pw1xZ');
In the above piece of code, we have set the value of Customer code.
DELETE operation
$cookies.remove('CustomerCode');
It simply removes the value in Cookies.
0 Comment(s)