I need to disable a button if a boolean variable (returned from back-end) is true.
This is my incomplete function on my angular controller, how do I change my controller and HTML button to make this work?
$scope.flagInLavorazione = function (flagInLavorazione) {
if (flagInLavorazione === true){
// What to add here?
}
}
You're looking for ng-disabled
. Simply assign it a property from your controller. When it's true
, the element will be disabled. Populate that property with the value from the back end.
对于 AngularJS,您可以使用:
<button ng-disabled="isNotReady">I'm a button</button>
Edit: According to your requirements, you would use:
$scope.disabilitaConvalida = function (flagInLavorazione) {
$scope.saldoNegativo = false;
if (flagInLavorazione === false) {
$scope.saldoNegativo = true;
}
}
And in your template:
<button ng-disabled="saldoNegativo"></button>
Original Answer:
You set in your template:
<button ng-disabled="condition"></button>
And
$scope.condition = true
or false
in your controller based on the backend variable.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.