以下のような複雑なオブジェクトがあります
someName = [
{name: "John",id: "1",rating: ['0', '1', '2', '3', '4', '5']},
{name: "robert", id: "2", rating: ['0', '1', '2', '3', '4', '5']},
{name: "luv", id: "3", rating: ['0', '1', '2', '3', '4', '5']}
];
そこから、以下のようにhtmlをレンダリングしているときに、回答を0〜5で評価するようにアンケートを作成したいと思います
<ng-container *ngFor="let sort of someName; let i=index">
<label id="example-radio-group-label">Rate your favorite section</label>
<mat-radio-group aria-labelledby="example-radio-group-label" class="example-radio-group" [(ngModel)]="sectionRating">
<mat-radio-button class="example-radio-button" *ngFor="let section of sort.sections" [value]="section">{{season}}</mat-radio-button>
</mat-radio-group>
</ng-container>
これは適切にレンダリングされていますが、最初の質問の評価を1として選択すると、他のすべての評価からも選択されます。また、これらの各評価を取得したいのです[(ngModel)]
が、配列ではなく1つの値しか与えません
私の .ts ファイルでは、次のようにモデル参照を配列として指定しました。
sectionRating: any[] = [];