Chr*_*ian 6 tabs angularjs angular-ui-bootstrap
我有三个静态选项卡和一个按钮,使用ng-click ="selectThirdTab()"
<div ng-controller="Ctrl">
<input type="button" value="Select third tab" ng-click="selectThirdTab()" />
<tabset justified="true">
<tab heading="First" active="isFirstActive"></tab>
<tab heading="Second" active="isSecondActive"></tab>
<tab heading="Third" active="isThirdActive"></tab>
</tabset>
</div>
Run Code Online (Sandbox Code Playgroud)
函数"selectThirdTab"如下:
$scope.selectThirdTab = function () {
$scope.isThirdActive = true;
}
Run Code Online (Sandbox Code Playgroud)
吸管在这里:Plunker
最初选择第一个选项卡,单击按钮,结果是选中的第三个按钮.现在,如果您选择其他选项卡,然后再次单击"选择第三个选项卡"按钮,则不会选择第三个按钮.怎么了?
或者你可以这样:
angular.module('plunker', ['ui.bootstrap']);
var Ctrl = function ($scope, $timeout) {
$scope.isActive = [{active:true},{active:false},{active:false}];
$scope.selectThirdTab = function () {
$scope.isActive[2].active = true;
}
}
Run Code Online (Sandbox Code Playgroud)
并在HTML中
<tabset justified="true">
<tab heading="First" active="isActive[0].active"></tab>
<tab heading="Second" active="isActive[1].active"></tab>
<tab heading="Third" active="isActive[2].active"></tab>
</tabset>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9590 次 |
| 最近记录: |