Вопрос

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