Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/380.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 拨动开关在角形无功形式内不工作_Javascript_Angular_Typescript_Toggle_Angular Reactive Forms - Fatal编程技术网

Javascript 拨动开关在角形无功形式内不工作

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

在我的angular 6应用程序中,我使用的是angular Responsive form,它在formarray中有一个三态切换开关

具有三种状态切换的Html:

      <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}}