2015-12-30 50 views
0

我有3個標籤(轉帳,存款和迷你賬單)的「交易」頁面。
我有一個包含菜單項的頁面。如果點擊該項目,想要打開交易頁面中的特定選項卡。在離子中打開特定標籤

我試着按以下方式而不是工作,即,只打開第一個選項卡

$scope.openAccountTabs = function(index){ 
    $state.go("Transactions"); 
    $ionicTabsDelegate.select(index); 
}; 

enter image description here

+0

發佈完整的代碼UI路由等 –

回答

1

好,它會採取很多的變化,使這個幹活都嘗試這樣做,它的working.try此

1:在狀態定義的變化,通過$stateParams

.state('app.my_tabs', { 
     url: "/{id:[a-zA-Z0-9]{1,24}}/{index:[a-zA-Z]{0,12}}", 
     cache:false, 
     views: { 
      '[email protected]': { 
       controller: 'TabCrtl', 
       templateUrl: "js/ModelOne/templates/TabView.html" 
      } 
     } 
    }) 

注意:id爲$ stateParams用於傳遞給與標籤UI不相關的API。

2:按鈕的點擊,通過指數,以往標籤想成爲開放(0 =第一個選項卡,1 =第二個標籤):上選在默認位置:

ui-sref="app.my_tabs({id:oneOrder._id,index:1})" 

3:在選項卡UI標籤,我曾嘗試在離子選項卡中使用ng-init,因此該方法只能調用一次。但它沒有工作:

<ion-tabs id="tab_view" class="tabs-top tabs-program tabs-color-positive"> 
    <ion-tab title="tab1" on-select="selectTabWithIndex()"> 

4:這裏是TabCrtl一些調整:

var firstIndex = $stateParams.index; 
    $scope.selectTabWithIndex = function() { 
     if(firstIndex != null) { 
      if (firstIndex == 1) { 
       console.log("$stateParams.index :" + firstIndex); 
       $ionicTabsDelegate.select(1); 
      } else { 
       $ionicTabsDelegate.select(0); 
      } 
      firstIndex=null; 
     } 
    } 

注:firstIndex=null;是剛停車檢查時,再次選項卡clicked.its我的壞邏輯條件,使你自己..!

多數民衆贊成它..hola,其工作..!一切順利。

+0

謝謝@ the_mahasagar..its工作就像魅力... – vishnu