質問

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