in my service.component.j . I am returning a Student observable array from an http call. The student object has a property called age,
student.ts
export class Student {
id: number;
name: string;
age:number;
}
service.componnet.js
getStudents (): Observable< Student[]>
In studentManagement.component.ts , which is an observer above the observed, I want to summarize the age of the students. I know that I can put sum () in the source code (which is less desirable, since I also need to display other information about Students on the page, for example, identifier, name, individual age) or calculate it from _studentList. Other than these two, in any other way?
private _studentList:Student[]=[];
.subscribe(
returnedStudents => {
console.log(returnedStudents);
this._studentList = returnedStudents;
},
erroMsg => this._errorMessage = erroMsg
)