// Dienstklasse zum Speichern von Anwendungsdaten import { Injectable } from '@angular/core'; @Injectable() export class StackService { public datas: any[] = []; add(obj: any): void { this.datas.push(obj); }; avg(fld: string): number { if (this.datas.length > 0) { return this.rnd(this.datas.reduce((s, o) => s + parseFloat(o[fld]), 0)/this.datas.length); }; return 0; }; rnd(val: number, digits: number = 2) { let pre = Math.pow(10, digits); return Math.round(val*pre)/pre; }; }