使用Angular 6补丁程序无法正常工作 [英] Patch form doesn't work well using Angular 6
本文介绍了使用Angular 6补丁程序无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您能问我任何想法吗,我在演示
我想在视图中显示名称城市,然后发布id_city.该演示有效,但如果我删除或添加项目,则此修补程序形式不起作用.
can you ask me any idea please, I have a problem in this demo
I want to show name city in view, and post id_city. This demo works, but if I remove or add items this patch form doesn't work.
我有这个控制权:
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)
});
})
推荐答案
只需更改tis:
(onSelectionChange)="updateFormProducts($event, item.name, 'city_id', i)"
对此:
(onSelectionChange)="updateFormProducts($event, item.city_id, 'city_id', i)"
这篇关于使用Angular 6补丁程序无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文