Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AngularJS : how to refresh object without data loss?

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

like image 746
Mohanrajan Avatar asked Feb 12 '15 14:02

Mohanrajan


1 Answers

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

like image 67
Robert Cadmire Avatar answered Sep 19 '22 18:09

Robert Cadmire