I have a use case where there the users will be greeted by -LoginPage (LoginController)
On login, login details & user information are added to the factory called UserData. The app will be directed to a tabbed controller. Information from UserData will be used to provide personalization, fill out $scope.displayName etc,.
.controller('DashCtrl', function($scope, userData) {
$scope.name = userData.data.name;
})
As caching is enabled, the respective tab dashboard controller is not getting fired.
It took a while to figure out that caching is enabled by default and had to be turned off
.state('tab.dash', {
url: '/dash',
cache: false,
views: {
'tab-dash': {
templateUrl: 'templates/tab-dash.html',
controller: 'DashCtrl'
}
}
})
-
Is it a good approach from IonicFramework to turn on caching by default? It might inconvenience the new users as they need to figure out why controller is not firing. I understand the trade-off : better performance
-
What are the the recommended coding approaches to make use of caching and pass data from login controller to tab based controllers through factories or other means.
-
Will the following code snippet benefit from caching as it will enter the watch cycle again
$scope.$on(’$ionicView.afterEnter’, function(){
// Any thing you can think of
});