I am using super heroic Angularjs in my application. I have a couple of pages like home.html
, project.html
, map.html
. Each pages has a controller associated with it e.g. HomeCtrl
, ProjectCtrl
, MapCtrl
. In my home.html
user can create a project or navigate to project.html
. In project.html
I have list of all projects. When user clicks on a project he is navigated to map.html
where I have some information regarding to project. I am using ngRoute
for routing between the views. I am facing some challenges to share data across the controllers. I have created a service called dataFactory
which stores all the data retrieved from backend. In my project.html
view, I load all the data from backend and store them in service. When user lands into a project I use data stored in the dataFactory
. The concern is that when user refreshes the page when he is on the map.html, all the data which are stored in dataFactory
are wiped out and not loaded back cause data loading happens in the project.html
page. I don't know how can I deal with it. I can not make a call to backend in every controller to get the data. I am planning to load the common data in app.run()
method. But in that case I have to broadcast/emit
the events to notify controllers, which will also be messier and will eventually lead to errors cause I know my application is going to be a huge application.