Categories
Angular Answers

How to disable button in Angular?

Spread the love

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.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *