Hamdy
Hamdy

Reputation: 440

Programmatically check ion-radio inside two ngFor

I would like to display radio buttons based on the input of a table. If the value of the check box is contained on the other table, the check box will be checked otherwise the checkbox will display normally

This is my code:

 <div *ngFor="let item of prelevementToDisplay">
  <ion-list radio-group *ngFor="let type of normePrelevementList; let i = index" [(ngModel)]="checkNorme">              
      <div *ngIf="type.name === item.normePrelevement">
        <ion-item>
          <ion-label>{{type.name}} </ion-label>
          <ion-radio [checked]="true"  value="{{type.name}}"></ion-radio>
        </ion-item>
      </div>

      <div *ngIf="type.name!== item.normePrelevement">
                <ion-item>
                  <ion-label>{{type.name}}</ion-label>
                  <ion-radio value="{{type.name}}"></ion-radio>
                </ion-item>
      </div>
</div>

How can I resolve this problem?

Upvotes: 1

Views: 779

Answers (1)

JGFMK
JGFMK

Reputation: 8914

You have a missing closing <ion-list> in your question. Perhaps that's it.

Also FYI there is an else to *ngIf too. See this example

And === is preferred over == Ignore the comment.

Upvotes: 1

Related Questions