请问我有什么主意,我对此demo有疑问
我想在视图中显示名称城市,然后发布id_city。该演示有效,但是如果我删除或添加项目,则此修补程序形式不起作用。
我有这个控制权:
city_id: this.client.forEach(x => {
x.city_id.forEach(cid => {
//this.formData.push(new FormControl(x.city_id))
let control = new FormControl(cid, Validators.required);
(<FormArray>this.myform.controls['city_id']).push(control);
setTimeout(()=>{
let cityName = this.city.find(c=> c.city_id == cid).name;
control.patchValue(cityName, {onlySelf: true, emitEvent:true});
},100)
});
})
答案 0 :(得分:0)
只需更改tis:
(onSelectionChange)="updateFormProducts($event, item.name, 'city_id', i)"
对此:
(onSelectionChange)="updateFormProducts($event, item.city_id, 'city_id', i)"