Monday, 16 March 2015

Angular cookies issue ($cookies , $cookieStore)


I will list my issues when I was using Angular cookies:


1,  I got an error when I was using:


   var favoriteCookie = $cookies.get('myFavorite');

the error was:

  " TypeError: 'undefined' is not an object"


Explanation:

I did this because I found that on Angular official website:

https://docs.angularjs.org/api/ngCookies/service/$cookies

They said all cookies operations should do via $cookies, and

Note: The $cookieStore service is deprecated. Please use the $cookies service instead.
However, they didn't mention,  in which version, they deprecated it!!!!!!!!!!

I checked my bower.json, I am using 1.3.x, and I checked source code of it. 1.3.x is not the version which deprecates it.

And then I checkout 1.4.x, and I found 1.4.x does.

I failed of using angular cookies by following their documentations, because they said it is deprecated by they didn't say in which version !!!!!! F*** ***!!!!!!

However, you may ask that: in my bower.json, all packageds are marked by "˜" or "^" but why bower didn't install the latest version for me ?

because all packages are related/requested each other. Complex!! maybe a package request a old version, you don't know. bower solve it for you automatically, If bower cannot solve it and a confliction was found, bower will popup this issue for you when you run "bower install"

For nodejs or bower package versions you can learn from:
http://baiduhix.blogspot.co.uk/2015/03/nodejs-or-bower-package-versions.html


Solution:

Use "$cookieStore" which they deprecated!!!!!!














No comments:

Post a comment