2

I want to display a div if a my check box is checked. This my form :

 repairForm = new FormGroup({
  inftwoEuro : new FormControl(true),
  measurement : new FormControl('')
  })

HTML :

<form class="k-form k-form-inline " style="padding-top:7px; padding-left: 0px;"
            [formGroup]="repairForm">
            <div class="col-md-12 no-padding-left">
              <input type="checkbox" formControlName="inftwoEuro" kendoCheckBox >
            </div>
            <div *ngIf ="inftwoEuro" class="col-md-12 no-padding-left">
              <input kendoTextBox class="k-textbox form-control"
               formControlName="measurement">
              </div>
        </form>

Here the div is always not displayed even the checkbox is checked or not I don't know why

1
  • Value true assign on global variable then after use *ngIf conditions. Commented Jan 7, 2021 at 11:24

2 Answers 2

1

Try with :

<div *ngIf="repairForm.get('inftwoEuro').value" class="col-md-12 no-padding-left">
  <input kendoTextBox class="k-textbox form-control" formControlName="measurement">
</div>

Juste here a working StackBlitz : https://stackblitz.com/edit/angular-ivy-3irrav?file=src/app/app.component.html

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

2 Comments

Hi thanks for answering ! but it still not working !
@hibanebli I edited my post and added a StackBlitz, please check
0

Ts File

inftwoEuro: any;

Inside constructor

constructor() {
this.inftwoEuro = false;
}
this.inftwoEuro = true;

HTML

<div *ngIf ="inftwoEuro" class="col-md-12 no-padding-left">
 <input kendoTextBox class="k-textbox form-control" formControlName="measurement">
</div>

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.