angularjs - How to make a tab active from the beginning in Angular Bootstrap UI? -


i'm trying make 1 of tabs active (tabs in template), depending on url params. unfortunately, make active default the first 1 found in html template, if use ng-repeat in example.

this doesn't work:

$scope.tabs = {         title2: {active:false, content:"hello world 2!"},         title3: {active:false, content:"hello world 3!"},         title4: {active:false, content:"hello world 4!"}     }     $scope.tabs.title4.active = true; 

here fiddle: http://jsfiddle.net/alexrada/kfaxh/5/

you need use $routeparams service inside controller , set the $scope active value it. along these lines:

.controller('mytabctrl', function($scope, $routeparams) {   $scope.tabs[$routeparams.active].active = true; }) 

where url /?active=title4

you need set $routeprovider service. i'll see if can fork of jsfiddle work once becomes usable again (it's soooo slow currently...)


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -