Angular app not working when web browser refreshed
-
21-12-2019 - |
Question
I have an angularJS app, It is working well till I refresh my web browser.
In my application, there is a JSON object that I get based on my login. It got a secession ID and a set of arrays in it. Once I refresh my web page, the JSON object become empty and error occurs where ever the JSON is related to. I get this JSON at the time of login.
What could be the issue? If you need, I can give more explanation.
Solution
Refreshing the webpage means resetting all JSON objects. You need cookies to save information even after they leave the page. Also if you detect that someone isn't logged in you should redirect them to the log in page.
Read up on cookies here: http://www.w3schools.com/js/js_cookies.asp http://docs.angularjs.org/api/ngCookies/service/$cookies