2017-03-02 165 views
1

切換活動類我怎樣才能在NG-重複切換一類的onclick每個item.My代碼執行時不work.Thank你,在NG-重複

這是我的代碼。

<a class="list-group-item" ng-repeat="connect in Connected" ng-click="getChat(connect.TokenId, connect.SessionId); getOnline(connect.SupportId, connect.TokenId, connect.SessionId, connect.CreateTime); onClickTab(connect.TokenId)" ng-class="{'active': $index == selectedIndex}" ng-init="$first && getChat(connect.TokenId, connect.SessionId); $first && getOnline(connect.SupportId, connect.TokenId, connect.SessionId, connect.CreateTime)"> 
       <h4 class="list-group-item-heading"><strong ng-bind="connect.SupportId"></strong></h4> 
       <ul class="list-unstyled"> 
        <li><strong>Token ID :<strong ng-bind="connect.TokenId"></strong> </li> 
        <li> 
        <strong>Online :</strong> 
        <span class="Connect" ng-if="connect.SessionId != undefined" class="ConnectIcon"><div class="ConnectIcon"></div></span> 
        </li> 
        <li><span>Chat Duration: </span> <strong ng-bind="connect.CreateTime | DateGap"></strong></li> 
       </ul> 
      </a> 

在我的控制器:

$scope.onClickTab= function(x){ 
     $scope.selectedIndex= x; 
    }; 
+0

只是使用'ng-class =「{'active':$ index == connect.TokenId}」' –

回答

1

您應該使用

onClickTab($index) 

不是ID。