i am fetching data in a table using ng-repeat in angularjs.the table contains id which i need to accept or reject. I want to disable other buttons ina row when one of the button is pressed.I am able to do it with tit using ng-disabled but the buttons of all rows are disabled..Can someone help..thankx
here's my code
<tr ng-repeat="result in results " >
<td>{{$index +1}}</td>
<td>{{result.companyName}}</td>
<td>{{result.id}}</td>
<td>{{result.createdAt}}</td>
<td>{{result.modifiedAt}}</td
<td>{{result.Status}}</td>
<td>
<button class="btn" ng-click="processStart(result.id)"> Approve </button>
</td>
<td>
<button class="btn" ng-click="processReject(result.id)" ng-disabled="showRejectButton" >
<span class="glyphicon glyphicon-remove"></span> Reject </button>
答案 0 :(得分:1)
问题是你有每个拒绝按钮绑定到ng禁用条件的同一个变量,即ng-disabled="showRejectButton"
。
您需要将每个按钮绑定到自己的变量。您可以使用$scope.showRejectButton
数组(然后在表中使用ng-disabled="showRejectButton[$index]"
)或将showRejectButton附加到每个结果对象(然后在表中使用ng-disabled="result.showRejectButton"
)来执行此操作。