2

I am a rookie in angular js. In my application, I want to save an object into $rootScope and do a post request which does not contain the object in rootScope.

In new page which has just opened, I want to use that object from rootScope but as I have understood, after a full redirection , rootscope loses its state or I am doing something wrong:)

In general, without a full refresh, is there a way to store variables into rootscope or should I have to pass it with each request from one to another?

THX

PS: I do not using ng-view and looking for something without ng-view...

1
  • 1
    Angularjs is SinglePageApplication FrameWork, so you cannot pass values to another page unless you store it in a cookie or local storage of a browser. Commented Nov 9, 2014 at 15:08

3 Answers 3

1

You may have to use the browser's local stroage, if that is an option.

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

Comments

0

if I well understand what you are looking for, I think you can do it with a Factory.....

    app.factory('myService', function() {
 var savedData = {}
 function set(data) {
   savedData = data;
 }
 function get() {
  return savedData;
 }

 return {
  set: set,
  get: get
 }

}

1 Comment

nop, this will not work because the page is not partially refreshing. It is a full redirection and all the scopes of angular will be created again.
0

I get it. After a full redirection , all the scopes are recreated by app itself. So there can not be any previous data in new scopes. In order to do that, the ng-app should not be refreshed and ng-view should be used, or webstore,cookie etc should be used.

Thx fellas

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.