Use case of $ionicView.loaded?

what is the use case of $ionicView.loaded?

what is the difference of

.controller('Ctrl', function ($scope) {
	$scope.$on('$ionicView.loaded', function () {
		//do something
	}
}

.controller('Ctrl', function ($scope) {
	//do something
}

i know that the //do something will run after $ionicView is loaded
from what i test from the above two snippet, the //do something code run immediately when i click a link
is there any special use case that I can use $ionicView.loaded or
is there any performance advantage?

I use $ionicView.loaded for analytics (“page views”) or tracking other events, it’s best to not think of it as a Controller init VS event and more of a way to add code execution after that event is fired as it will be called no matter what view is loaded where as your controller is loaded for a specific state.

1 Like

the ionic is triggered when the ion-view added to the dom.
if you are not listening you are executing your code when the controller is instantiate

Does-it impact the number of angular watchers, digest cycles or something like that ?

And, as @soocheng asked, is there any difference in term of performance ?