diff --git a/src/app/content/poule/poule.component.ts b/src/app/content/poule/poule.component.ts index 91a216c..589ab28 100644 --- a/src/app/content/poule/poule.component.ts +++ b/src/app/content/poule/poule.component.ts @@ -1,4 +1,4 @@ -import {Component, Input, OnInit} from '@angular/core'; +import {Component, Input, OnChanges, OnInit, SimpleChanges} from '@angular/core'; import {ChampionshipService} from '../../championship.service'; @Component({ @@ -6,7 +6,7 @@ import {ChampionshipService} from '../../championship.service'; templateUrl: './poule.component.html', styleUrls: ['./poule.component.scss'] }) -export class PouleComponent implements OnInit { +export class PouleComponent implements OnInit, OnChanges { @Input() poule: number; @@ -26,6 +26,10 @@ export class PouleComponent implements OnInit { } ngOnInit() { + this.loadData(); + } + + private loadData() { console.log('POULE COMP: ' + this.poule + ' ' + this.idChampionship + ' ' + this.tier); // fetch the poule data this.championshipService.getTeamsInPoule(this.idChampionship, this.tier, this.poule).subscribe(val => { @@ -85,9 +89,9 @@ export class PouleComponent implements OnInit { } const totalTimes: number[] = []; - for(let raceNr = 0; raceNr < this.maxRaces; raceNr++) { + for (let raceNr = 0; raceNr < this.maxRaces; raceNr++) { const raceTime = this.getRaceTime(raceNr, idTeam); - if(raceTime) { + if (raceTime) { totalTimes.push(raceTime); } } @@ -131,4 +135,10 @@ export class PouleComponent implements OnInit { return this.timesIndexed[idTeam][raceNr].laptimesms; } + ngOnChanges(changes: SimpleChanges): void { + console.log('onchanges called...'); + console.log(changes); + this.loadData(); + } + }