【发布时间】:2016-12-27 07:16:50
【问题描述】:
我有一个 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
但在 for each 完成之前启用按钮,因为 forEach 中的$timeout。如何在 forEach 期间禁用按钮并在迭代后重新启用它。
【问题讨论】: