Sometimes, we want to disable button in Angular.
In this article, we’ll look at how to disable button in Angular.
How to disable button in Angular?
To disable button in Angular, we set the [disabled]
attribute.
For instance, we write
<button [disabled]="!editmode ? 'disabled' : null" (click)="loadChart()">
<div class="btn-primary">Load Chart</div>
</button>
to set the [disabled]
attribute to 'disabled'
if editmode
is false
.
Otherwise, we set it to null
to keep the button enabled.
Conclusion
To disable button in Angular, we set the [disabled]
attribute.