Home > OS >  How to replace a string with a variable in an angular *ngIf
How to replace a string with a variable in an angular *ngIf

Time:09-07

I have a div in my template which i want to hide base on a value of a certain form control and that's where I run into some issues. The below format works fine

<div *ngIf="form.value[question.key] ==='other'">

But the issue is how do i replace the 'other' with a value from my question object called childhidevalue i tried [question.childhidevalue], ['question.childhidevalue'] and {{question.childhidevalue}} with no luck.

CodePudding user response:

Try this:

<div *ngIf="form.value[question.key] === question.childhidevalue">
  • Related