【发布时间】:2020-10-30 15:06:33
【问题描述】:
我正在为我的动态表单组件中的选择项使用自定义材料自动完成输入。正如我所说,表单字段是动态的,要过滤项目列表,每次用户在输入中输入内容时,我都必须更改列表。
filteredOptions: { [key: string]: Observable<PickListItem[]> } = {}; key 是 controlName 的名称, PickListItem 是要选择的项目列表。
在某些情况下,用户可以将自己的选项添加到列表中,之后有 API 请求返回更新的项目列表,这是我的问题:我想用新列表替换旧列表(更新)。
有人可以帮我吗?
this.componentsApiService.addPicklistItem(field.Attributes.List.ID, this.addInputOption)
.pipe(
finalize(() => {
this.store.dispatch(new StopLoading('shared.saving'));
}),
takeUntil(this.componentDestroyed$))
.subscribe( result /*updated list*/ => {
this.filteredOptions[field.Label] = <= here I want to assign observable updated list, dont know how to do this
this.addInputOption = '';
}, ({error}) => {
this.snackBarService.error(error.message);
});
【问题讨论】:
标签: javascript arrays angular rxjs subscription