The $ cookies object has no properties

I am trying to use the $ cookies service using angular 1.4.0-beta.2.

The cookie created by the server goes to document.cookie as well as to $cookies . but $cookies are just a simple object. when I check console.dir($cookies) there are only keys / values โ€‹โ€‹inside. where get() , put() , getAll() functions?

I tried to check the simplest code example from https://docs.angularjs.org/api/ngCookies/service/ $ cookies

  angular.module('cookiesExample', ['ngCookies']) .controller('ExampleController', ['$cookies', function($cookies) { // Retrieving a cookie var favoriteCookie = $cookies.get('myFavorite'); // Setting a cookie $cookies.put('myFavorite', 'oatmeal'); }]); 

but that will not work. This is probably trivial, but what am I missing?

+7
angularjs cookies
source share
2 answers

Have you forgotten to update "angular-cookies" too? it is a plugin, so updating "angular" will not work.

I use 1.4.0-rc.1 and it works (with updating "angular-cookies" to "1.4.0-rc.1" of course)

+1
source share

I had the same problem. After updating both angular-cookies and angular to the latest version, everything worked as expected. Thanks, tommyTheHitMan, for pointing me in the right direction.

-one
source share

All Articles