【发布时间】:2019-02-05 02:01:56
【问题描述】:
我有两个 Observable<MyType> 的 Observable 数组类型
export interface MyType{
title: string;
id: string;
other: [];
}
如果项目存在于第二个数组中,我想将附加属性 exists 添加到第一个数组并将其设置为 true:
const combined$ = combineLatest(this.first$, this.second$);
this.output$ = combined.pipe(
map((x, y) => {
return x.map(a => {
a.title = a.title;
a.id = a.id;
a.other = a.other;
a.exists = y.find(b => b.id === a.id )
});
})
);
如果订阅output observable this.output$.subscribe(console.log);,总是得到[...undefined] 结果
任何想法如何解决?
【问题讨论】:
标签: angular rxjs angular2-observables