-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期間禁用按鈕並在迭代後啓用它。