retain angular variables after page refresh

前端 未结 5 1201
一个人的身影
一个人的身影 2020-12-03 17:01

I\'m trying to figure out a way to keep my angular variables with page refresh / across controllers. My workflow is,

  • user logs in via facebook an
5条回答
  •  被撕碎了的回忆
    2020-12-03 17:47

    I did the same using $window.localStorage.

    It is kind of similar to accepted answer.

    var token = "xxx";
    $window.localStorage.setItem("token",token);
    $window.localStorage.getItem("token"); //returns "xxx"
    $window.localStorage.removeItem("token"); //deletes token
    

提交回复
热议问题