i can set cookie fine,how ever if cookie name setting "cookie code 1" gets saved "cookie%20code%201"
. how solve issue spaces in between words?
self.cookie=function(){ localstorageservice.cookie.set("cookieid",decodeuricomponent(self.id), 100000); }
the official doc $cookiestore says following:
provides key-value (string-object) storage, backed session cookies. objects put or retrieved storage automatically serialized or deserialized angular's tojson/fromjson.
means, serialize , unserialize (urlencoded) happens automatically. promise using plugin atm https://github.com/grevory/angular-local-storage#cookieget, serialize/unserialize. use localstorageservice.cookie.get(key);
check callback.
myapp.controller('mainctrl', function($scope, localstorageservice) { //... function setandgetitem(key) { localstorageservice.cookie.set(), "its cookie"); // persisted "its%20a%20cookie" console.log(localstorageservice.cookie.get(key)); // returns "its cookie" } //... });
Comments
Post a Comment