0

I have a ng-table in my webapp with a lot of rows per page (up to 1000). I also have a select-all checbox that call a function ng-change to set the flag selected to true in each table row. The function require some seconds to be executed so user can click two or more time on the checkbox and i want to prevent this. I would like to disable the checkbox while the function is executed. Is it possible to do this? Thanks

0

2 Answers 2

1

perhaps you can create some marker for ng-disable. like this:

<input type="checkbox" ng-disabled="inProgress">

and in controller when treated your function add this marker:

$scope.runYourFunction = function() {
 $scope.inProgress = true;
 ....... your function ........
 $scope.inProgress = false; // in the end. it will enabled your checkboxes; 
}
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for answer, the problem is that I'll see the checbox disabled only once the function is ended and if i click two times on checkbox the function will be executed two times
@DavideCampello The first thing that runYourFunction does above is set $scope.inProgress = true to disable your checkbox. It then does the function call that will take several seconds. Seems to be exactly what you need
0

A very simple solution, not necessarily optimal, would be to update a logical property in your controller (set to true when the function is executed and back to false when finishes) and use a "ng-disabled" directive based on that property in your check-box.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.