我动态创建了单选按钮,并检索了打字稿中的值,并进行了必要的修改。现在,这些值将显示在动态创建的文本框中(分别为文本框)。但是我不能。请帮助
<table><tr>
<td>Middle Name</td>
<td *ngFor='let data of SourceProvider; index as i'>
<input type="radio" [(ngModel)]="radioSelected" (change)="radioButtonChange()" id="rdoMiddleName" name=data.MiddleName value={{data.MiddleName+i}}>
<label>{{ data.MiddleName }}</label>
</td>
</tr></table>
<table><tr>
<td>Middle Name</td>
<td *ngFor='let data of SourceProvider; index as i'>
<input [attr.id]="'lblMiddleName'+i" type="text" value={{radioset}}> <!-- [(ngModel)]="radioset" -->
</td>
</tr></table>
Ts代码
radioButtonChange()
{
this.fetchIndex = this.radioSelected.charAt(this.radioSelected.length-1); // take index for textbox dynamic name
this.radioset = this.radioSelected.slice(0, -1); //remove index (last character)
this['lblMiddleName' + this.fetchIndex] = this.radioset;
}