I'm using AngularJS 1.4.0 and the $cookies
service. The following code will always print out an empty object:
(function() {
var app = angular.module("user-cookies-service", []);
app.service('UserCookiesService', ["$cookies", function($cookies) {
$cookies.put("Hello", "World");
console.log($cookies.getAll());
}]);
})();
I've tried:
- Using AngulerJS 1.3.15 and
$cookieStore
where cookies don't persist when the browser is refreshed (but it at least created the cookies).
- Adding an expiry date.
- Making sure Cookies are enabled in my browser (Chrome).
- Trying plain old JS, which still doesn't work.
I haven't been able to find a similar issue anywhere.
Thank you.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…