I want a way to store a local variable that will remain there even if I changed the path ( The page) or the angular app. I tried $window.localStorage.set and get item and they didn't work as well as rootScope and $window.variable

share|improve this question
    
what about using localStorage? - I feel is the only option you can use when changin angular app. Also, what do you mean by changing the angular app ? You want to persist something accross different apps ? – Gonzalo.- Apr 20 at 17:55
    
yes like a variable that I can access from different angular apps and I used localStorage, I edited the question – Mahmoud Youssef Apr 20 at 17:57
    
is this like an environment variable? or something dynamic? – Murwa Apr 20 at 21:49
up vote 0 down vote accepted

If you want to store the values in local storage you would use:

localStorage.setItem({identifier}, {value});

Then to retrieve your value you would use:

localStorage.getItem({identifier});
share|improve this answer
    
I can't send objects using this way I can only send a single variable – Mahmoud Youssef Apr 20 at 20:20
    
@MahmoudYoussef You are storing the value in local storage and you access it with the identifier. What do you mean you cannot store an object this way? – Ken Apr 21 at 20:19
    
The issue is solved what I meant was that I couldn't send an object through this method but it turned out I can. What I meant by Object is an array of any type not only a string – Mahmoud Youssef Apr 22 at 12:04

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.