【问题标题】:Angular groupby and merge array角度分组和合并数组
【发布时间】:2020-07-08 20:54:47
【问题描述】:

1

我正在尝试合并数组中的重复值对象,但无法正常工作... I have my result like this

but I want my data like this help me pls

这是我的代码

-

     dataa = [
           {
             date: '07/05/2020 00:09',
             id: '5920501995',
             score: 0,
             student: 'boon boon',
           },
          ....] 
source = from(this.dataa);
//group by age
 example = this.source.pipe(
  groupBy(person => person.id),
  // return each item in group as array
  mergeMap(group => group.pipe(toArray())));
 subscribe = this.example.subscribe(val => console.log(val));
 - 

【问题讨论】:

    标签: angular toarray mergemap


    【解决方案1】:

    你可以推送到另一个变量而不是记录

    const values= [];
    const subscribe = example.subscribe(val => {
    values.push(val);
    });
    

    【讨论】:

      猜你喜欢
      • 2019-01-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-09-28
      • 1970-01-01
      • 2019-02-28
      • 1970-01-01
      相关资源
      最近更新 更多