Angular 分组并合并数组
Angular groupby and merge array
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));
-
您可以推送到另一个变量而不是记录日志
const values= [];
const subscribe = example.subscribe(val => {
values.push(val);
});
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));
-
您可以推送到另一个变量而不是记录日志
const values= [];
const subscribe = example.subscribe(val => {
values.push(val);
});