【发布时间】:2020-02-03 04:26:08
【问题描述】:
我有一个发射器,它发出一个对象数组,如下例所示。
ServerDropdownOption
name: "Just Closed Buyers"
selected: true
value: "leadbucket::07727388-500A-4ED0-BB5A-1BB4718F1AFC"
__proto__: Object
我使用的代码使用 switchMap 只返回每个对象的值。
this.chipsSelect.multiSelectBox.onSave
pipe(
takeWhile(_ => this.alive),
filter((tag) => tag.selected === 'true'),
switchMap(updatedSelection => this.contactsService.updateBuckets(this.contactId, updatedSelection.map(tag => tag.value))) )
.subscribe();
我现在需要的是还根据所选值进行过滤,并返回该值为 true 的值。问题是它会产生以下错误。
类型“IOptionMultiSelectBox[]”上不存在属性“selected”
export interface IOptionMultiSelectBox {
name: string;
value: any;
selected: boolean;
}
所以我的 IOptionMultiSelectBox 具有 selected 属性,但从我的 observable 返回的 dat 是一个对象数组。那么我该如何解决这个问题,以便过滤器正常工作?
【问题讨论】: