Use for dynamic object property names in angular reactive form

你。 提交于 2019-12-25 01:42:57

问题


In code below

<div *ngSwitchCase="'arraytext'" >
      <label class="col-sm-6" [formArrayName]="question.key" *ngFor="let order of form.controls.options.controls; let i = index">
      <input type="checkbox" [formControlName]="i" class="form-control">{{order.value}}
      </label>
</div>

Here options is checkbox input for dynamic form and for another checkbox input may be option-2.

So my question is how to have form.controls.options.controls dynamic instead of using hard-coded options

Demo. Here I managed to get the checkbox values, but the problem is how to have more than one checkbox. form.controls.options.controls is hard coded

来源:https://stackoverflow.com/questions/58010831/use-for-dynamic-object-property-names-in-angular-reactive-form

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!