Gabriel Anzaldo Alvarado Gabriel Anzaldo Alvarado - 5 months ago 73
AngularJS Question

Angularjs: Why page refresh destroy the values of $rootScope?

In my local route http://localhost:9000/#/deviceDetail/ I have a controller that manage that view. Before going to that view I set some variables to the

(for example

Once on that view I have acces to dashboards property, but when I refresh the page with
key for example the property dashboards is lost.

I tried to save the
on the localStorage variable but I got circular reference problems with the

Any tip to manage that?


AngularJS is a JavaScript framework, everything is stored in memory heap and the heap is starts when you open a page and it's destroyed after you close it. In this context, browser refresh is like closing and re-opening the page.

To keep the value after refresh, you should store it in a cookie, for this you use for example $cookies or sessionStorage / localStorage as recommended by M K.