WebSQL based app and views cache

Hello,

I make an app with SQLite and for each view, in the controller, I have to get some data from my SQL database.
In UIRouter when I enable the cache my controller is not instantiated each time so my data are not updated in the view.

I know I can use the resolve or onEnter options of UIRouter but I think this way is not clean because I have to use a service and I don’t want to have a 20 lines or more controllers inside my route config.

Actually my cache is disabled and I use a ‘setView’ function in my controllers. So, the question is, how to request the database each time a view is loaded in a cleaner way ?

Example of controller :

function homeController($stateParams, $q, ngdb, my_visits) {
	var vm = this;
	vm.savedVisits = [];
	vm.calendarVisits = [];

	setView();

	///////////

	function setView() {
		var visitsRepository = ngdb.getRepository('visits');
		var visits = visitsRepository
			.setBy({'search_id': $stateParams['searchId']})
			.setOrder({'last_update': 'DESC'})
			.get();

		visits.then(function(result) {
			var visits = my_visits.distinctVisits(result);

			vm.calendarVisits = visits['calendar'];
			vm.savedVisits = visits['saved'];
		});
	}
}

Thank you :slight_smile: