how do return the $state.current.name from ui-router statechange

前端 未结 4 1497
野性不改
野性不改 2020-12-28 13:49

I would like to return the .state(\'name\') when I change location in angular.

From my run() it can return the $state object:

4条回答
  •  太阳男子
    2020-12-28 14:33

    You can listen for '$stateChangeSuccess' and set state accrodingly. For example -

    $rootScope.$on('$stateChangeSuccess',
      function(event, toState, toParams, fromState, fromParams) {
        $state.current = toState;
      }
    )
    

提交回复
热议问题