angular1.4.8中的cookie操作

ngCookies版本也是1.4.8特别声明了版本号,希望后人不要入坑在angular1.4.8中引入ngcookie插件不能注入$cookieStore而改为注入$cookieStore,$cookies比如下面这段就是 的

angular.module('cookieStoreExample', ['ngCookies']) 
.controller('ExampleController', ['$cookieStore', function($cookieStore) { 
 // Put cookie 
 $cookieStore.put('myFavorite','oatmeal'); 
 // Get cookie 
 var favoriteCookie = $cookieStore.get('myFavorite'); 
 // Removing a cookie 
 $cookieStore.remove('myFavorite'); 
}]); 

利用$cookieStore操作cookie会报循环获取xxx错误具体大家试试就行了只需要改一处地方代码就可以完美运行那就是把 改为其他操作方法不变

angular.module('cookieStoreExample', ['ngCookies']) 
.controller('ExampleController', ['$cookies', function($cookies) { 
 // Put cookie 
 $cookies.put('myFavorite','oatmeal'); 
 // Get cookie 
 var favoriteCookie = $cookies.get('myFavorite'); 
 // Removing a cookie 
 $cookies.remove('myFavorite'); 
}]);