문제

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