-1
我有一个HTML按钮,必须启用或禁用基于范围变量。我根据条件为每个动作分配启用/禁用动作。对于这种情况,我需要$timeout
。
vm.isDisable = true;//disbles the button before forEAch
//vm.gridData, which is array of object haves more than 1000 rows
angular.forEach(vm.gridData,function(rows){
if(rows.isSelectedRow == true) {
$timeout(function(){
vm.gridApi.selection.selectRow(rows);
})
});
vm.isDisable = false; //enables the button after for each
但启用前的每完成按钮,因为$timeout
在foreach内。如何在forEach期间禁用按钮并在迭代后启用它。