$ stateChangeStart不被解雇的UI-路由器ES6状态发生变化时? [英] $stateChangeStart not being fired when state Changes in UI-Router ES6?
问题描述
我使用巴布尔的ES6和的WebPack。我对角1.x.x和构建应用程序。到现在为止我没有打任何问题。我想有一个功能,我可以跟踪所有的路由变化。我使用的UI的路由器。问题是, $ stateChangeStart
是没有得到反正触发。在code为如下所述。
I am using Bable for ES6 and webpack. I am on angular 1.x.x and building an application. Till now I did not hit any problem. I want to have a functionality where I can track all the Route Changes. I am using UI-Router. The problem is that $stateChangeStart
is not getting triggered anyways. The code is mentioned below.
/*All includes are taken care of. Please look at the run method*/
angular.module('chpApp', [
uirouter,
angular_animate,
uibootstrap,
formly,
formlyBootstrap,
ngMessages,
angularLoadingBar,
'ngNotificationsBar',
'jkuri.datepicker',
'LocalStorageModule',
'ncy-angular-breadcrumb',
'mgo-angular-wizard',
'luegg.directives',
'ngToast',
'ui.mask',
/*Application Modules*/
angularnvd3,
chpConstants,
menu,
header,
breadcrumb,
auth,
dashboard,
programs,
device
])
.run(['$rootScope', function($rootScope) {
$rootScope.$on('$stateChangeStart', () => {
console.log('lol')
})
}])
.config(routing);
请让我知道,因为状态得到改变,但 $ stateChangeStart
事件永远不会触发我是个做错了。在运行
方法是我在哪里挂钩与 $ stateChangeStart
监听的地方。
Please let me know what I ma doing wrong because the state is getting changed but the $stateChangeStart
event never gets triggered. The run
method is the place where I am hooking up with the $stateChangeStart
listener.
我猜它是与ES6,我无法找到任何引用。
谢谢你。
I guess its something to do with ES6 and I am not able to find any reference. Thanks.
推荐答案
我也有类似的问题,并最终实现了 stateChange *
事件已经去precated并默认在 UI路由器
1.0禁用。我使用 1.0.0-alpha0
。
这些事件所提供的功能现在可以使用的过渡钩的实现。这是包括在发行说明1.0 alpha和可以在这里阅读:的 https://github.com/angular-ui/ui-router/releases/tag/1.0.0alpha0
I had a similar problem and eventually realised that the stateChange*
events have been deprecated and disabled by default in ui-router
1.0. I'm using 1.0.0-alpha0
.
The functionality provided by these events can now be achieved using transition hooks. This is covered in the release notes for the 1.0 alpha and can be read here: https://github.com/angular-ui/ui-router/releases/tag/1.0.0alpha0
这篇关于$ stateChangeStart不被解雇的UI-路由器ES6状态发生变化时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!