1

I have a angularjs app which reads json from java when the user is logged in:

$http({ method: 'POST', url: 'ws/login/user', data : user, cache: true })
.success(function (response) {                                                    
    $rootScope.userInfo = response; // Here I get the json                                          
    response = { success : true };                    
    callback(response);
}).error(function (response) {
    response = { success : false };
    response.message = 'Error.';
    callback(response);
});

Everything works fine until I press F5, then the JSON disappears.

How can I keep the data between page loads?

4
  • Java or JavaScript? The two are totally different. Commented Mar 13, 2015 at 22:14
  • The backend is developed in Java. I'm using RESTful service to get the json. Commented Mar 14, 2015 at 1:25
  • Why is the application in need of a hard refresh in the first place? Commented Mar 14, 2015 at 3:02
  • Is not necessary for the application. Is just to prevent accidental refresh by users. Commented Mar 14, 2015 at 13:11

2 Answers 2

2

You can use cookies or Local Storage. A quick google search shows this library: https://github.com/grevory/angular-local-storage.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you so much! I've solved using LocalStorage! It's really useful, thanks again!
0

Modern web applications will use local storage to keep data between page loads. Here is a helpful answer to get you started.

How do I store data in local storage using Angularjs?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.