onExit 中的 $rootScope

$rootScope in onExit

我想在状态更改时在 onExit 中使用 $rootScope.$broadcast()

但是为此,我需要在.config()中注入$rootScope,这在angular

中是不可能的
 onExit: function () {
                //onExit is executed when we leave that state and go to another
                $rootScope.$broadcast('broadCastCloseModalStr');
            }

有人可以帮我实现吗?

使用$injector$rootScope注入onExit,就像这样

onExit: function($injector) {
    var rootScope = $injector.get('$rootScope');
    console.log("onExit: ", rootScope);
}

但是,这也应该有效

onExit: function($rootScope) {
    console.log("$rootScope: ", $rootScope)
}

这是一个有效的 plunk