New in TypeScript — Angular 2.
I wondering to know how to calculate a sum from a list.
I already selected the items needed and get the sum with a error :
TS Error Type 'void' is not assignable to type 'Creance[]',
creancesOfSelectedRemise: Creance[];
onSelectRemise(remise: Remise, event: any) {
...//...
this.creancesOfSelectedRemise = this.creances
.filter(c => c.id_remettant === remise.id_remettant)
.forEach(c => this.totalCreances += c.creance_montant);
}
It seems 'forEach' is not used correctly.
Is it possible to add the filter and the forEach in the same time ?
thanks Bea