You will need to write your own tube, below should give you what you need. It takes the attribute of the object you want to sum as a parameter
Amount
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'sum'
})
export class SumPipe implements PipeTransform {
transform(items: any[], attr: string): any {
return items.reduce((a, b) => a + b[attr], 0);
}
}
Use it like you would use any other channel
<span>{{ balances | sum:'balances' }}</span>
The average
, . null 0.
transform(items: any, attr: string): any {
let sum = items.reduce((a, b) => a + b[attr], 0);
return sum / items.length;
}