Reputation: 4613
According to the official doc, ion-view will emit its life-cycle events to help us control its logic.
But how can I catch these events?
Upvotes: 9
Views: 7429
Reputation: 5469
You can attach the events with the $scope
in the relevant controller.
angular.module('ionicApp', ['ionic'])
.controller('HomeTabCtrl', function($scope) {
$scope.$on('$ionicView.loaded', function (viewInfo, state) {
console.log('CTRL - $ionicView.loaded', viewInfo, state);
});
$scope.$on('$ionicView.unloaded', function (viewInfo, state) {
console.log('CTRL - $ionicView.unloaded', viewInfo, state);
});
});
Upvotes: 12