Reputation:
I have a form with save button.Once the data is loaded in the form then only I need to enable the save button.
How to disable a button in angular 2? This might sound simple.
Things I tried
1 - [disabled]="true"
but it does not work.
2 - [disabled]="!isValid"
but it does not work.
Upvotes: 1
Views: 1253
Reputation: 2784
Declare the button on the template like:
<button [disabled]="disableButton">Send</button>
Then on your component declare the variable:
disableButton = true;
When your data is loaded you simply activate the button:
this.disableButton = false;
Upvotes: 1