1

单击按钮时,我不想禁用所有按钮以防止任何其他操作。为此,我使用request.isProcessing布尔值。一开始function approve(request)我设置request.isProcessingtrue,最后设置为false

但这不起作用。(对于 ng-repeat 中的请求request.isProcessing不会改变)

是因为我在不同的scope地方还是什么?

<div class="one-third" ng-repeat="request in pendingRequests track by request.id">
   ...
   <div class="button-container">
       <button ng-click="approve(request);" ng-disabled="request.isProcessing" class="btn btn-primary">Confirm<i ng-hide="request.isProcessing" class="fa fa-check"></i><span ng-show="request.isProcessing" class="spinner no-hover"><a><i class="fa-li fa fa-spinner fa-spin"></i></a></span></button>
       <button ng-click="reject(request);" ng-disabled="request.isProcessing" class="btn btn-default pull-right" am-hide-request-resolve-div>Reject <i ng-hide="request.isProcessing" class="fa fa-times"></i><span ng-show="request.isProcessing" class="spinner no-hover"><a><i class="fa-li fa fa-spinner fa-spin"></i></a></span></button>
   </div>
</div>

$scope.approve = function (request) {
        request.isLoading = true;
        //functionality of approving
        request.isLoading = false;
}
4

1 回答 1

2

在 javascript 中,您的变量是isLoading,而在您的 HTML 中,变量是isProcessing. 所以我想你应该重命名其中一个。

于 2016-05-20T09:48:26.477 回答