AngularJS: how to update an object without data loss?

I used two different controllers (suppose myCtrl1 and myCtrl2), and I set the button to myCtrl1. When we click this button, the action goes to myCtrl2 through an ajax call. Now I add some data to the .service () object and redirect the page using $state.go('tabs.myCtrl1) . Now I can not get the added data in the object. But when the application loads the first time you run an empty object in .service ().

Will anybody help me

+6
source share
1 answer

This may not be the best method, but you can store data in $ rootscope.variableName, which would allow access to data all over the world, otherwise it will not be erased when switching between controllers

+1
source

Source: https://habr.com/ru/post/982386/


All Articles