Accessing cookies in angular.js
$cookiestore is a wrapper around $cookies, they only work with session $cookies. You can use local storage, jquery.cookie plugin. When pulling out the data their is a slight difference between using $cookiestore and $cookie to store value. You need to inject ngCookies into app definition as :angular.module('myApp', ['ngCookies']);
When accessing cookies you should first include angular.js. Then include angular-cookies.js. After that inject ngCookies into your app module and make sure that you have referenced that module in the ng-app attribute. Now add a $cookie or $cookieStore parameter to the controller. Then access the cookie as a member variable using the dot operator. If you want to access cookieStore use put/get methods.
Comments
0 comments
Please Sign in or Create an account to Post Comments