简体   繁体   中英

Bootstrap AngularJS make tabs active

I know this has been asked a lot but it does not work for me. I simply want to make a tab appear active when it has been clicked. Heres what i already got:

 app.config(['$routeProvider', function( $routeProvider){ $routeProvider. when('/maschinen', { templateUrl: 'maschinen.xhtml', controller: 'mainController', activetab: 'maschinen' }). when('/personen', { templateUrl: 'personen.xhtml', controller: 'mainController', activetab: 'personen' }). when('/qualifikation', { templateUrl: 'qualifikationen.xhtml', controller: 'mainController', activetab: 'qualifikation' }); }]); 
 <ul id="tabs" class="nav nav-pills nav-justified"> <li ng-class="{active: $route.current.activetab == 'index'}" data toggle="tab"><a ng-click="go('/index')">Home</a></li> <li ng-class="{active: $route.current.activetab == 'maschinen'}" data-toggle="tab"><a ng-click="go('/maschinen')">Maschinen/Tätigkeiten</a></li> <li ng-class="{active: $route.current.activetab == 'personen'}" data-toggle="tab"><a ng-click="go('/personen')">Personen</a></li> </ul> 

Try this:

In html:

<a ng-click="go('/index')>...</a>

In controller:

$scope.go = function(url)
{
    $location.path(url);
}

Hope this help.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM