Angular-ui-router: ui-sref-active and nested states

前端 未结 8 1040
独厮守ぢ
独厮守ぢ 2020-12-02 10:06

I am using angular-ui-router and nested states in my application, and I also have a navigation bar. The nav bar is hand written, and uses ui-sref-active to high

8条回答
  •  渐次进展
    2020-12-02 10:56

    So Simple, Step 1: Add a Controller for your nav bar orin your existing controller where nav bar is included add the following

    app.controller('navCtrl', ['$scope', '$location', function($scope, $location) {
            $scope.isActive = function(destination) {
            return destination === $location.path();
        }
    
    }]);
    

    Step2: In your nav bar

  • Browse Journal
  • Thats it.

提交回复
热议问题