Reputation: 123
I want to write a function in typescript, let's name it 'isActive()', and call it on a button in my html file. I also have a boolean value called 'isActive' declared. Suppose I have 2 buttons, when I click button 1, isActive() is called and if isActive value is set to false, button 2 is disabled. Any help?
Upvotes: 1
Views: 6792
Reputation: 1354
Based on your question, what I understood is:
There are total two buttons: A and B. Out of which, if A is clicked then based on value of the updated variable you want to disable button B
If this the requirement then you can use "click" event from Angular. E.g. here
Your HTML
<button id="a" (click)="fnl($event)">A</button>
<button id="b" [disabled]="!isActive">B</button>
Your TS
fnl(e) {this.isActive=!this.isActive}
don't forget to declare isActive as class variable
Upvotes: 3