訪問控制的值的形式陣列AM經由表單生成器與REST API結果在angular2
的陣列設置我的形式這是我的表單生成代碼
this._inspectionService.getChecklists(this.truckParam)
.subscribe(
res=> {
this.checklists = res;
let inspectionform: FormGroup;
let checkinputs: FormArray = new FormArray([]);
for (let i = 0; i < this.checklists.length; i++) {
checkinputs.push(
new FormGroup({
description:new FormControl(this.checklists[i].item),
input: new FormControl(''),
yesradio: new FormControl(''),
noradio: new FormControl(''),
})
)
}
this.inspectionform = this._formBuilder.group({
inputfileds: this._formBuilder.array(checkinputs.controls)
})
},
);
現在在我的形式
<form [formGroup]="inspectionform">
<ion-card *ngFor='let checklists of inspectionform.controls["inputfileds"]["controls"]
;let i=index'>
//at this stage i can access
{{checklists.controls["description"].value}} //it retuns a value
//NOW AM trying to connect the form control inputs via
<ion-input type="text" formControlName='checklists.controls["noradio"]'>
IVE ALSO TRIED
<ion-input type="text" formControlName='checklists.controls.noradio'>
而返回的錯誤是
Cannot find control with name: 'checklists.controls["noradio"]'
我要去哪裏錯了
是否在代碼中輸入了拼寫錯誤代碼或僅在這裏? 無論如何,請嘗試formControlControlName ='{{checklists.controls [「noradio」]。value}}'... – Arwin
是不是inspectionform.controls [''] ... – wesside
不在表單構建器上拼錯它我實際上把它作爲輸入文件 –