1

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?

1
  • I don't get why this question is down voted. Is this not a programming question?!! Commented Aug 12, 2018 at 7:27

1 Answer 1

3

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.