I have folowing table:
<ng-container *ngFor='let data1 of sectionList'>
<tr>
<td>
{{data1.name}}
<button (click)="ArrRow($event)" style="float: right" id="{{data1.id}}">+</button>
</td>
</tr>
<tr *ngFor="let data2 of (model.Register10Data | filter:'sectionGroup':data1.id); let dataIndex = index">
<td>
{{data2.SomeNumericValue}}
</td>
</tr>
<tr><td>Here I need to summing of the data2.SomeNumericValue</td></tr>
</ng-container>
In this table I'm using @pipe for grouping data. Pipe looks like:
@Pipe({
name: 'sectionGroup'
})
export class FilterPipe implements PipeTransform {
transform(items: any[], field: number, value: number): any[] {
if (!items) return [];
return items.filter(it => (+it[field]) === (+value));
}
}
This works fine.
I need get summation of data2.SomeNumericValue
that's rendering within *ngFor with pipe. But summation must be rendered outside *ngFor. Above in the example I wrote where it should be.
Real table contains many columns and rows. And rows can be added dynamically. By some columns i want get summation. I know how to write function and render result in cell. But I think that summation must calculated inside *ngFor because it is reduce count of iterations. But maybe i'm wrong. How to do this and which method is the best?