我正在使用角度6和材质组件,其中我制作了一个单选按钮组,其中提供了两个选项供选择,其中我已使用ngModel来获取所选单选按钮的值,但在第一个上获取未定义的值单击并在单击另一个选项的同时获取先前选择的值,请在下面给出帮助代码:-
App.Component.html
<mat-radio-group formControlName="offers" [(ngModel)]="offers">
<mat-radio-button value="freeShipping" (click)="offerStatus(offers)">Free shipping</mat-radio-button>
<mat-radio-button value="nextDay" (click)="offerStatus(offers)"> Next Day</mat-radio-button>
</mat-radio-group>
App.component.ts
offerStatus(data){
console.log(data);
}
输出
undefined //when selecting any one of the options
freeShipping //when selecting nextDay option
nextDay //when selecting freeShipping
预期产量
freeShipping // when selecting freeShipping
nextDay // when selecting nextDay
答案 0 :(得分:1)
使用Person_ID DAY metric1 metric2
-----------------------------
A 1 x [null]
A 2 y b
A 3 [null] a
代替change
click