I create an algorithme which sum different data.
this.http.get(url)
.subscribe(result => {
this.lineup = result.json();
this.lineup = Array.of(this.lineup);
for(let i = 0; i < this.lineup['0']['data'].latest['data'].length; i++){
let fix = this.lineup['0']['data'].latest['data'][i];
this.fix = this.lineup['0']['data'].latest['data'];
this.fix.sort(function (a, b) {
a = new Date(a.time.starting_at.date);
b = new Date(b.time.starting_at.date);
return a<b ? 1 : a>b ? -1 : 0;
});
let lined = this.fix[i].lineup['data'][i];
this.lined = this.fix[i].lineup['data'];
this.lined = this.lined.filter(lined => lined.player_id === 580);
this.cards = this.lined['0'];
if(this.cards != undefined) {
this.note = 5;
console.log("first",this.note);
this.note = this.note + (0.8 * this.cards.stats.goals.scored);
this.note = this.note - (0.4 * this.cards.stats.goals.conceded);
this.note = this.note + (0.1 * this.cards.stats.shots.shots_total);
this.note = this.note + (0.2 * this.cards.stats.shots.shots_on_goal);
this.note = this.note + (0.1 * this.cards.stats.fouls.drawn);
this.note = this.note - (0.4 * this.cards.stats.fouls.committed);
this.note = this.note - (0.4 * this.cards.stats.cards.yellowcards);
this.note = this.note - (3 * this.cards.stats.cards.redcards);
this.note = this.note + (0.2 * this.cards.stats.passing.crosses_accuracy);
this.note = this.note + (0.01 * this.cards.stats.passing.passes);
if (this.cards.stats.passing.passes_accuracy > 80) {
this.note = this.note + (0.5);
} else {
this.note = this.note - (0.5);
}
this.note = this.note + (0.4 * this.cards.stats.other.assists);
this.note = this.note - (0.3 * this.cards.stats.other.offsides);
this.note = this.note + (0.01 * this.cards.stats.passing.passes);
this.note = this.note + (1 * this.cards.stats.other.saves);
this.note = this.note + (2 * this.cards.stats.other.pen_saved);
this.note = this.note - (1.5 * this.cards.stats.other.pen_missed);
this.note = this.note - (1 * this.cards.stats.other.pen_committed);
this.note = this.note + (0.3 * this.cards.stats.other.hit_woodwork);
this.note = this.note + (0.3 * this.cards.stats.other.tackles);
this.note = this.note + (0.3 * this.cards.stats.other.blocks);
this.note = this.note + (0.4 * this.cards.stats.other.interceptions);
this.note = this.note + (0.1 * this.cards.stats.other.clearances);
console.log('note finale', this.note)
}
});
The problem, with my console log, I have 1 note for each array like this :
player.ts:260 note finale 8.400000000000002
player.ts:260 note finale 8.64
player.ts:260 note finale 7.38
player.ts:260 note finale 8.839999999999998
player.ts:260 note finale 7.040000000000001
player.ts:260 note finale 8.78
player.ts:260 note finale 7.84
player.ts:260 note finale 9.700000000000001
player.ts:260 note finale 7.760000000000001
But in my html file, only last note is showing :
<ion-col *ngFor="let event of fix" col-6 style=" font-size: 19px;padding: 3px;vertical-align:middle;color:#4B4B4B;text-align: left; padding-left:5%;">
{{event.localTeam.data.name}} - {{note}}
</ion-col>
Any idea? Thanks.