AngularJS - UI Router stateChangeSuccess event not firing

后端 未结 3 1912
终归单人心
终归单人心 2021-01-01 12:06

I am using UI Router in my angular app. I am trying to integrate state change events, but they are not firing on state change. Everything else is working fine a

相关标签:
3条回答
  • 2021-01-01 12:26

    If you are using the new ui-router (v1.0.0), the $stateChange* events will not work. You must use $transitions.on* hooks from now on.

    You can read here.

    https://ui-router.github.io/docs/latest/modules/ng1_state_events.html

    https://github.com/angular-ui/ui-router/issues/2720

    0 讨论(0)
  • 2021-01-01 12:33

    $state events are deprecated for angular version > 1.0.0. now onward for change event we have to use $transitions

    refer $transitions from here

    0 讨论(0)
  • 2021-01-01 12:35

    StateChange events has been deprecated for ui.router >= 1.0

    for the new ui.router use the following

    StateChangeSuccess

    $transitions.onSuccess({}, function() {
      console.log("statechange success");
    });
    

    StateChangeStart

    $transitions.onStart({}, function(trans) {
     console.log("statechange start");
    });
    

    Check this migration guide for more information

    0 讨论(0)
提交回复
热议问题