When do controllers get instantiated? Is it the first time you visit that state? also, What happens when you revisit the state, does a new controller get instantiated again?
Assume that I have two states, A and B, and I put an alert statement at the top of state B. I noticed that if go from state A to B state B's alert statement sets off which tells me that the controller got instantiated. But suppose I go from state A to B to C and back to B, the alert statement does NOT go off. However, if I go from state A to B to C to B to A to B the alert statement goes off again.
Here is a part of my routes:
state A = app.login
state B = app.pincodeCreate
state C = app.messagelist
.run ($ionicPlatform, startup) ->
$ionicPlatform.ready(startup.ionicReady)
.config (googleAnalyticsCordovaProvider, $stateProvider, $urlRouterProvider) ->
$stateProvider
.state('app', {
url: '/app',
abstract: true,
templateUrl: 'templates/menu.html',
controller: 'AppController'
})
.state('app.pincodeCreate', {
url: '/pincode',
views: {
menuContent: {
templateUrl: 'templates/pincode.html',
controller: 'PincodeController'
}
}
})
.state('app.login', {
url: '/login',
views: {
menuContent: {
templateUrl: 'templates/login.html',
controller: 'LoginController'
}
}
})
.state('app.messagelist', {
url: '/messagelist',
views: {
menuContent: {
templateUrl: 'templates/messagelist.html',
controller: 'MessageListController',
resolve: {
activities: (utils, store, $state) ->
utils.getActivities().then ((activities) ->
store.isUserLoggedIn(true)
activities
), (error) ->
$state.reload()
}
}
}
})