Angularjs - 如果任何值超过 ng-repeat 元素值,如何禁用提交按钮

Angularjs - How to disable submit button if any value exceeds the ng-repeat element value

我有这样的程序。

var app = angular.module("myApp", []);
app.controller("myCtrl", function($scope) {
  $scope.records = [
    {
      "Amt" : "500",
      
    },
    {
      "Amt" : "800",
     
    },
    {
      "Amt" : "1580",
    },
    {
      "Amt" : "1122",
    }
  ]
  
  $scope.value=function(d, x)
  {
    x.balance = x.Amt - d;
    if(d > x.Amt){
    $scope.isExceeded = true;
  } else {
    
    $scope.isExceeded = false;
  }  
  }
});
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<body ng-app="myApp">

<table ng-controller="myCtrl" border="1">
  <tr>
  <td>Amt</td>
  <td>Balance</td> 
  <td>Entered Amt</td>
  <td ng-if="error"> Error</td>
</tr>
<tr ng-repeat="x in records">
  <td>{{x.Amt}}</td>
  <td>{{x.balance}}</td>
   <td><input type="text" ng-model="d" ng-change="value(d, x)"></td>  
  <td ng-if="d > x.Amt" ng-model="error">Please enter less than {{x.Amt}}</td>
</tr>
<tr>
  <td colspan="4"><input type="button" value="Submit" ng-disabled="isExceeded"></td>
</tr>
</table>

</body>
</html>

我想要的是,如果任何输入的金额值超过金额值,提交按钮应该被禁用。

我不知道如何实现这种 condition.I angularjs 的新功能。

您可以有一个变量 isExceeded 并在 angular 标记中使用它和 ng-disable 指令来禁用按钮。

<body ng-app="myApp">   
   <table ng-controller="myCtrl" border="1">
     <tr>
       <td>Amt</td>
       <td>Balance</td> 
       <td>Entered Amt</td>
       <td ng-if="error"> Error</td>
     </tr>
     <tr ng-repeat="x in records">
       <td>{{x.Amt}}</td>
       <td>{{x.balance}}</td>
       <td><input type="text" ng-model="d" ng-change="value(d, x)"></td>  
       <td ng-if="d > x.Amt" ng-model="error">Please enter less than {{x.Amt}}</td>
     </tr>
     <tr>
       <td colspan="4" ng-disable="isExceeded"><input type="button" value="Submit"></td>
     </tr>
   </table>    
</body>

并在 angular 控制器中检查它,如

$scope.value=function(d, x)
{
  if(d > x.Amt){
    $scope.isExceeded = true;
  } else {
    x.balance = x.Amt - d;
    $scope.isExceeded = false;
  }  
}