【发布时间】:2020-08-30 13:35:40
【问题描述】:
我使用Angular 9,我有一个这样的嵌套表单:
createFormGroup() {
return this.formBuilder.group({
Id: new FormControl(0),
Name: new FormControl(''),
Children: this.formBuilder.array([
this.formBuilder.group({
Id: new FormControl(0),
Autocomplete: new FormControl('', [Validators.required])
})
])
})
}
我需要访问此 n Autocomplete 以订阅事件和显示推荐。
通常我在有一个控件时使用它来访问
this.filteredData = this.myform.controls['Autocomplete'].valueChanges.pipe(
startWith < string | any > (''),
map(value => typeof value === 'string' ? value : value.name),
map(name => name ? this._filter(name) : this.mylist.slice())
);
感谢大家的帮助。
【问题讨论】:
标签: angular typescript angular-reactive-forms nested-forms