Material: md-tab how to active and focus tab from my controller function call

Created on 15 Mar 2016  路  6Comments  路  Source: angular/material

From my nav menu I want to active and focus perticular tab how can i do it ?
Anyone pleas give me example for active tab from my nav view
Also tab is dynamic and menu item list same as tab list

Most helpful comment

@bhandaribhumin Here is a quick example that shows you how to change tabs programmatically using the md-selected attribute:

http://codepen.io/topherfangio/pen/wGgmLq?editors=1010

If you still have trouble; please ask on the forums as GitHub is really only for submitting bugs :smile:

All 6 comments

Please post this on the forums.

please let me know if you know
i want to share issued in forums also.
and see this video to how exactly problem i face
https://drive.google.com/file/d/0B0qdA1kUoM_hUTdUT3NCd2ltRTg/view?usp=sharing

@bhandaribhumin Here is a quick example that shows you how to change tabs programmatically using the md-selected attribute:

http://codepen.io/topherfangio/pen/wGgmLq?editors=1010

If you still have trouble; please ask on the forums as GitHub is really only for submitting bugs :smile:

no not working when by default i set my md-selected="3" whichis also not working don't know what's the problem? i am stuck please help me

$scope.selectedIndex = 1; is not working while controller load
i just check $scope.selectedIndex = 2; but not working on controller first load
and also not working wile i call function and change $scope.selectedIndex = 3; or $scope.selectedIndex = 4;
from my nav bar

nav-menu .html

ng-repeat="(cat_id, categorie) in catTabTitle"
ng-click="getItems(cat_id,$index)">

category.html

in category controller

initialize $scope.selectedIndex = 1;

$rootScope.getItems = function(cat_id,index){
console.log('cat id');
$scope. selectedIndex = index+2;
$mdSidenav('left').close();

}

https://drive.google.com/file/d/0B0qdA1kUoM_hWUtPUTdrMUlzV2M/view?usp=sharing

when i click on $rootScope.getItems(), check selectedIndex value it's seems like

$scope.$watch('selectedIndex', function(current, old){
console.log('current',current);
console.log('old',old);
});

Console output
current 2
old 3

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sbondor picture sbondor  路  3Comments

kasajian picture kasajian  路  3Comments

buzybee83 picture buzybee83  路  3Comments

WebTechnolog picture WebTechnolog  路  3Comments

ddimitrop picture ddimitrop  路  3Comments