使用AngularJS tabs指令,有没有办法从按钮中选择一个选项卡。我想要做的就是点击“选择标签3”按钮,然后选择第三个标签。
<md-button id="button" class="md-raised">Select Tab Three</md-button>
<div ng-cloak>
<md-content>
<md-tabs md-dynamic-height md-border-bottom>
<md-tab label="one">
<md-content class="md-padding">
<h1 class="md-display-2">Tab One</h1>
</md-content>
</md-tab>
<md-tab label="two">
<md-content class="md-padding">
<h1 class="md-display-2">Tab Two</h1>
</md-tab>
<md-tab label="three" id="three">
<md-content class="md-padding">
<h1 class="md-display-2">Tab Three</h1>
</md-content>
</md-tab>
</md-tabs>
</md-content>
</div>
答案 0 :(得分:2)
您可以在md-tabs中使用md-selected属性来选择所选标签https://material.angularjs.org/latest/api/directive/mdTabs
<md-button id="button" ng-click="selectedTab = 2" class="md-raised">Select Tab Three</md-button>
<div ng-cloak>
<md-content>
<md-tabs md-selected="selectedTab" md-dynamic-height md-border-bottom>
<md-tab label="one">
<md-content class="md-padding">
<h1 class="md-display-2">Tab One</h1>
</md-content>
</md-tab>
<md-tab label="two">
<md-content class="md-padding">
<h1 class="md-display-2">Tab Two</h1>
</md-tab>
<md-tab label="three" id="three">
<md-content class="md-padding">
<h1 class="md-display-2">Tab Three</h1>
</md-content>
</md-tab>
</md-tabs>
</md-content>
</div>