gpt4 book ai didi

javascript - 如何防止多次单击 AngularJS 中的 anchor 标记?

转载 作者:行者123 更新时间:2023-11-30 14:59:53 26 4
gpt4 key购买 nike

我已经创建了共享功能,它会起作用但是

//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) {
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>

多次点击 a 标签后列表重复,用户列表一次又一次重复。请告诉我如何解决重复问题?

最佳答案

试试这个

$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>

关于javascript - 如何防止多次单击 AngularJS 中的 anchor 标记?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46710296/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com