【发布时间】:2018-03-10 21:32:18
【问题描述】:
我有一个带有复选框的表格。它有一个 select ALL javascript 函数和一个 select one by one 函数。对于删除按钮,我的 html 文件如下所示:
<button data-toggle="modal" data-target="#rejectModal" contenteditable="false" id="delbutton" ng-model="delbutton" ng-disabled="countChecked() == 0">Delete</span></button>
全选复选框:
<th class="">
<input type="checkbox" name="select" id="checkAll" ng-model="selectAllRawSCP"/>
</th>
表格详情:
<tr ng-repeat=" item in rawSCAP | orderBy:sort">
<td>
<input type="checkbox" name="select" value="checked" ng-model="item.checked"/>
</td>
如果没有选中复选框,我使用了我在堆栈溢出中的一个答案中看到的代码来禁用删除按钮。它看起来像这样:
$scope.countChecked = function(){
var count = 0;
angular.forEach($scope.rawSCAP, function(value){
if (value.checked) count++;
});
return count;
}
但是使用这个,我的页面返回一个错误 isTypeError: Cannot read property 'checked' of null
即使我使用全选,我也需要启用删除按钮
【问题讨论】:
-
你能把plunker插在这里吗?
-
循环中$scope.rawSCAP的值是多少
标签: javascript html angularjs disabled-input