0

Am iterating through items and i would lie to show an input box if a certain radio button is checked

This is the form

<ion-card *ngFor="let checklist of checklists;let i=index">

   <input type='radio' name="check{{checklist.id}}" value='yes_{{checklist.id}}'> Yes


   <input type='radio' name="check{{checklist.id}}" value='no_{{checklist.id}}'> Not passed


       <ion-item [hidden]="">//hide when Not passed radio is not checked
         <ion-label floating>Comment</ion-label>
         <ion-input type="text"></ion-input>
       </ion-item>

</ion-card>

How do i hide the comment area when no is not checked and show it only when checked

1 Answer 1

1
   <input #notPassed type='radio' name="check{{checklist.id}}" value='no_{{checklist.id}}'> Not passed


       <ion-item [hidden]="notPassed.value == '...'">//hide when Not passed radio is not checked

(I don't know what actual values you are using, therefore just ...)

Hint: not tested myself yet.

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

8 Comments

The value of not passed radio button is determined but the index of ((*ngFor="let checklist of checklists;let i=index")) that is the value of i. Ive tried adding [hidden]="notPassed.value == 'no_{{checklist.id}}" and am getting an error of Got interpolation ({{}}) where expression was expected
You can't use [] and {{}} at the same time. Try ` [hidden]="notPassed.value == 'no_' + checklist.id"`
Okay the error dissapears but the input field always remains hidden even when checked
When i check on the inspect element the value of the radio doesnt change when checked
Sorry, don't know about the radio. I haven't ever used one myself.
|

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.