6

I have used two different controllers (assume: myCtrl1 and myCtrl2) and I set a button on myCtrl1. When we hit this button the action goes to myCtrl2 via ajax call. Now I'm append some data on .service() object and redirect the page using $state.go('tabs.myCtrl1). Now I can not get the appended data in object. But when app loads the first time it reads empty object in .service().

Anyone help to me

3
  • It would help if you created an illustrative example. Between "go to myCtrl2 via ajax" and "append some data on .service" it's easy to get lost Commented Feb 12, 2015 at 15:29
  • You can either create some MainCtrl which would be declared above these two controllers or you can use some service to store the data. Or you use localStorage if you want to store data for longer time Commented Feb 13, 2015 at 7:40
  • Thank you Mr.David. I resolve the issue by following your comment. Commented Feb 15, 2015 at 7:15

1 Answer 1

1

It may not be the best method but you can store data in $rootscope.variableName which would allow the data to be accessed globally aka it wont get wiped when you switch between controllers

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

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.