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

前端 未结 4 1499
野性不改
野性不改 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:38

    If you want to console your state in the controller then you should console like that:

    console.log($state.current.name);
    

    And if you want to console it in views then:

    In controller :

    $scope.state = $state.current.name;
    

    In Template: print like that

    {{state}}
    

提交回复
热议问题