Angular and $cookies - $cookies.get is not a function

后端 未结 3 1379
独厮守ぢ
独厮守ぢ 2020-12-15 03:20

I\'m trying to use cookies within Angular - here\'s what I\'m trying:



        
3条回答
  •  無奈伤痛
    2020-12-15 03:57

    The syntax you have is for version 1.4.x but you are referencing an older version. If you do not want to update to 1.4.x, you can use $cookieStore instead as follows:

    $cookieStore.put("key", "value"); 
    var value = $cookieStore.get("key");
    

    Alternatively if you are using version 1.3.x or below, you can use $cookies as follows:

    $cookies.key = "value";
    var value = $cookies.key; 
    

提交回复
热议问题