0

I have a text box which is disabled using simple disabled html tag. I need to enable it when I click checkbox, again I need to disable it when i uncheck the checkbox.

2

2 Answers 2

0

    checkValue = false;
    InputDisabled = true;

    ChangeEvent(){
        if(this.checkValue)
        {
          this.InputDisabled = false;
        } else
        {
          this.InputDisabled = true;
        }
      }
    <label for="">Add text to destination filename?</label>
    <input class="form-check-input" type="checkbox" [(ngModel)]="checkValue" (change)="ChangeEvent()" id="flexCheckDefault">
    <label for="">Text</label>
    <input type="text" style="width: 100px;" [disabled]="InputDisabled">

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

1 Comment

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
0

You can use ngModels in Angular to see enable/disable the button. Also, renember that you can need to create the variable of the ngModel on your AppComponent.

I create a test project for you: https://stackblitz.com/edit/angular-ivy-npvbz5?file=src/app/app.component.html

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.