$rootscope value used in a controller is overridden when refreshing the page used with that controller

后端 未结 2 779
醉话见心
醉话见心 2021-01-13 22:36

In my angularjs page I am passing a global data to another controller using the $rootscope object of angularjs. In my controller i am successfully able to catch the value st

2条回答
  •  囚心锁ツ
    2021-01-13 23:10

    If you reload your page all information that you store in JavaScript variables are lost. $rootScope is nothing more then a variable in JavaScript. If you want to store something that persists a page reload there are at least the following possibilities:

    • use a Cookie (in angular you could use the $cookieStore)
    • use some of the new HTML5 features like Locale Storage, Web DB or the old DOM Storage (http://en.wikipedia.org/wiki/Web_storage)
    • store your data on a server

提交回复
热议问题