我在formbuilder中有一个表单数组,我正在动态更改表单,即从应用程序1等单击加载数据.
我遇到的问题是所有数据都加载但是formarray中的数据保持不变,只是用旧的方式将旧项目连接起来.
如何清除formarray只有新项目.
我试过这个
const control2 = <FormArray>this.registerForm.controls['other_Partners'];
control2.setValue([]);
Run Code Online (Sandbox Code Playgroud)
但它不起作用.
有任何想法吗?谢谢
在nginit
ngOnInit(): void {
this.route.params.subscribe(params => { alert(params['id']);
if (params['id']) {
this.id = Number.parseInt(params['id']);
}
else { this.id = null;}
});
if (this.id != null && this.id != NaN) {
alert(this.id);
this.editApplication();
this.getApplication(this.id);
}
else
{
this.newApplication();
}
}
onSelect(Editedapplication: Application) {
this.router.navigate(['/apply', Editedapplication.id]);
}
editApplication() {
this.registerForm = this.formBuilder.group({
id: null,
type_of_proposal: ['', Validators.required],
title: ['', [Validators.required, Validators.minLength(5)]],
lead_teaching_fellow: ['', [Validators.required, Validators.minLength(5)]],
description: ['', [Validators.required, Validators.minLength(5)]],
status: '', …Run Code Online (Sandbox Code Playgroud)