2016-08-04 181 views
0

In this plunk我有三個從數組創建的選項卡。當我點擊按鈕時,我需要選擇名爲「名稱1」的那個,並有焦點。這怎麼能實現?如何以編程方式選擇Angular UI上的選項卡?

HTML

<uib-tabset> 
    <uib-tab ng-repeat="t in tabs" heading="{{t.title}}" > 
    {{t.content}} 
    </uib-tab> 
</uib-tabset> 


<br/><br/><br/> 
<button ng-click="tabs.select(1)">Focus on Name 1</button> 

的Javascript

$scope.tabs = [ 
    { title:'Name 0', content: "Content 0" }, 
    { title:'Name 1', content: "Content 1" }, 
    { title:'Name 2', content: "Content 2" } 
    ]; 

回答

4

你必須設置active屬性,如下圖所示:在您的按鈕,然後

<uib-tabset active="active"> 

<button ng-click="active = 1">Focus on Name 1</button> 

這是分叉Plunker

相關問題