When plural sets of angular cycles radio, a respective value acquired value

ngModel bound multiple sets of radio led to a string out of the loop, and select one

<div *ngFor="let item of list,let i = index">
<nz-radio-group nzName="{{item.id}}" [(ngModel)]="radioValue">
       <label [ngStyle]="style" nz-radio nzValue="A">{{item.a}}</label>
       <label [ngStyle]="style" nz-radio nzValue="B">{{item.b}}</label>
       <label [ngStyle]="style" nz-radio nzValue="C">{{item.c}}</label>
       <label [ngStyle]="style" nz-radio nzValue="D">{{item.d}}</label>
   </nz-radio-group>
</div>
public radioValue: '';

Solution:

When plural sets of radio, receiver array should be used

public radioValue: string[] = [];

ngModel binding item in the array subscript

<nz-radio-group nzName="{{item.id}}" [(ngModel)]="radioValue[i]">

This will get to the respective val

Guess you like

Origin www.cnblogs.com/webmc/p/12175690.html