【发布时间】:2020-12-14 12:32:55
【问题描述】:
我正在这样做:
const rawValues = this.filterList.map(s => {
return {[s.filterLabel]: s.selectedOption}
});
filterList 变量有这种类型:
export interface SelectFilter {
filterLabel: string;
options: Observable<any>;
selectedOption: string;
}
现在rawValues 被映射成这样:
[
{filterLabel: selectedOption},
{filterLabel: selectedOption},
{filterLabel: selectedOption}
]
所以这是我的新对象的数组,
但我想要的是一个 SINGLE 对象,所以最终结果应该是:
{
filterLabel: selectedOption,
filterLabel: selectedOption,
filterLabel: selectedOption
}
请注意,“filterLabel”将始终是唯一的。
我需要在map() 中进行哪些更改?
【问题讨论】:
标签: javascript angular angular8