Suppose we have an /example route and the ExampleCtrl associated:

.when('/example', {
    templateUrl : 'example.html',
    controller: 'ExampleCtrl'
})

&

ExampleCtrl = function(){
    $scope.$on("$routeChangeSuccess", function(){
       // is this guarantied to be called inside current scope?
    }
}

Most of the time the $routeChangeSuccess event will fire inside the newly created scope, but can I rely on this assumption?

有帮助吗?

解决方案

Welcome to StackOverflow ;)

$scope.$on...

that bit stands for listening to event $broadcast. As long as you don't consume event and stop propagation on purpose you can be certain that event indeed will be fired on new scope

hope that answers your question

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top