Javascript 拨动开关在角形无功形式内不工作
在我的angular 6应用程序中,我使用的是angular Responsive form,它在formarray中有一个三态切换开关 具有三种状态切换的Html:Javascript 拨动开关在角形无功形式内不工作,javascript,angular,typescript,toggle,angular-reactive-forms,Javascript,Angular,Typescript,Toggle,Angular Reactive Forms,在我的angular 6应用程序中,我使用的是angular Responsive form,它在formarray中有一个三态切换开关 具有三种状态切换的Html: <div class="switch-toggle switch-3 switch-candy"> <ng-container #buttonIcon *ngFor="let option of options" > <input
<div class="switch-toggle switch-3 switch-candy">
<ng-container #buttonIcon *ngFor="let option of options" >
<input
type="radio"
formControlName="state"
[id]="option"
[value]="option" />
<label
[attr.for]="option">
{{option}}
</label>
</ng-container><a></a>
</div>
{{option}}
请单击上面链接中的添加按钮查看输入
例如,单击“添加”按钮三次,从而添加了三行,这里第一行的切换开关单独工作,其余行的切换开关不工作。。即使切换是在第二行或第三行中进行的,也只会更改第一行
请帮助我为每行设置唯一的切换开关,并分别检索每行中的切换值。这是因为您所有标签和输入的id都是相同的。将html更改为
<div class="switch-toggle switch-3 switch-candy">
<ng-container #buttonIcon *ngFor="let option of options" >
<input
type="radio"
formControlName="state"
[id]="option+i"
[value]="option" />
<label
[attr.for]="option+i">
{{option}}
</label>
</ng-container><a></a>
</div>
{{option}}