我有一个像这样的mdTabs设置:
<md-tabs md-dynamic-height md-border-bottom>
<md-tab label="The first tab" id="first-tab-wrapper" class="tab-wrapper">
</md-tab>
<md-tab label="The second tab" id="second-tab-wrapper" class="tab-wrapper">
</md-tab>
</md-tabs>
<button>GO TO SECOND TAB</button>
当用户点击button
时,浏览器应转到第二个mdTab。我该怎么做?
答案 0 :(得分:1)
您可以使用md-selected
跟踪标签:
有效/选定标签的索引
HTML:
<md-tabs md-dynamic-height md-border-bottom md-selected="selectedTab">
<md-tab label="The first tab" id="first-tab-wrapper" class="tab-wrapper">
</md-tab>
<md-tab label="The second tab" id="second-tab-wrapper" class="tab-wrapper">
</md-tab>
</md-tabs>
<button ng-click="selectTab()">GO TO SECOND TAB</button>
JavaScript的:
$scope.selectTab = function() {
//go to second tab
$scope.selectedTab = 1;
}