2017-10-12 101 views
1

我已經創建共享功能將是工作,但之後的一個標籤和用戶列表,並再次重複again.so多時間點擊重複如何防止在AngularJS中多次點擊錨標籤?

//HERE WE CREATE THE CONTOLLER FOR SHARING 
 
$scope.selectedSharedBuyerKeyList  = []; 
 
$scope.selectedSharedBuyerObjectList = []; 
 
$scope.productObjectForShareModal  = []; 
 

 
$scope.getConnectedSharedUser   = function(product) { 
 
$scope.productObjectForShareModal = product; 
 
var data = { 
 
    productKeyId : $scope.productObjectForShareModal.keyId 
 
} 
 

 
//Call the getSharedUserList function for get the detail of the shared connectedUsers 
 
SellerDashboardService.getSharedUserList(function(response) { \t \t \t \t 
 
    if(response != null) { 
 
     if (response.data.isProduct) { 
 
     $scope.selectedSharedBuyerKeyList = response.data.sellerProductsDto; 
 

 
     // Obtaining user object.. 
 
     $scope.selectedSharedBuyerObjectList = []; 
 
     for(var selectedSharedBuyerKey of $scope.selectedSharedBuyerKeyList) { 
 
      var data = selectedSharedBuyerKey; 
 
      //call the getBuyerInShared for get the list of the objects 
 
      SellerDashboardService.getBuyerInShared(function(response) { 
 
      if(response != null) { 
 
       if (response.data.isbuyer) { 
 
       var buyerObject = response.data.isbuyer; 
 
       $scope.selectedSharedBuyerObjectList.push(buyerObject); 
 
       } 
 
      } 
 
      },data); 
 
     } 
 
     } 
 
    } 
 
},data); 
 
}
<a href="#" class="fa fa fa-group btn btn-xs pull-left bg-color-d4" 
 
    data-toggle="modal" data-target="#groupModal" 
 
    ng-click="getConnectedSharedUser(productDBList)"> 
 
</a>

名單告訴我如何解決重複問題?

+0

第一次點擊後禁用按鈕 –

+0

先生我使用面板不是一個按鈕,以及如何禁用它? –

+0

試試我的答案如下,它應該爲面板工作也 –

回答

1

試試這個

$scope.selectedSharedBuyerObjectList = []; 
$scope.productObjectForShareModal  = []; 

$scope.cliked=false ///set click to false 



$scope.getConnectedSharedUser   = function(product) { 
$scope.productObjectForShareModal = product; 
var data = { 
    productKeyId : $scope.productObjectForShareModal.keyId 
} 

//Call the getSharedUserList function for get the detail of the shared connectedUsers 
SellerDashboardService.getSharedUserList(function(response) {    
$scope.clicked =true; ///set it back to true 
    if(response != null) { 
     if (response.data.isProduct) { 
     $scope.selectedSharedBuyerKeyList = response.data.sellerProductsDto; 

     // Obtaining user object.. 
     $scope.selectedSharedBuyerObjectList = []; 
     for(var selectedSharedBuyerKey of $scope.selectedSharedBuyerKeyList) { 
      var data = selectedSharedBuyerKey; 
      //call the getBuyerInShared for get the list of the objects 
      SellerDashboardService.getBuyerInShared(function(response) { 
      if(response != null) { 
       if (response.data.isbuyer) { 
       var buyerObject = response.data.isbuyer; 
       $scope.selectedSharedBuyerObjectList.push(buyerObject); 
       } 
      } 
      },data); 
     } 
     } 
    } 
},data); 
} 



<a href="#" class="fa fa fa-group btn btn-xs pull-left bg-color-d4" 
    data-toggle="modal" ng-disabled="cliked" data-target="#groupModal" 
    ng-click="getConnectedSharedUser(productDBList)"> 
</a> 
1

我在角2所做的是我已經禁用的第一次點擊的按鈕。

E.g.

<button (click)="someFunction()" [disabled]="disableButton"></button> 
someFunction() { 
     disableButton = true; 
} 

注意:語法是你的情況不同,但邏輯將是相同的。 我希望這會有所幫助。