fix iterating in games bar

This commit is contained in:
cyber-dream 2022-10-18 18:17:12 +03:00
parent 26b5056bcd
commit d0313ad119
2 changed files with 4 additions and 4 deletions

View File

@ -1,4 +1,4 @@
<div class="games"> <div class="games">
<app-game-item [active]="i === activeGame" *ngFor="let game of games; index as i" [game]="game" (click)="activeGame = i"></app-game-item> <app-game-item [active]="game.gameId === activeGame?.gameId" *ngFor="let game of games; index as i" [game]="game" (click)="activeGame = game"></app-game-item>
</div> </div>
<app-game-info *ngIf="activeGame !== null" [game]="games[activeGame]"></app-game-info> <app-game-info *ngIf="activeGame !== null" [game]="activeGame"></app-game-info>

View File

@ -9,7 +9,7 @@ import { GetGames } from 'src/app/services/go';
}) })
export class GamesBarComponent implements OnInit { export class GamesBarComponent implements OnInit {
games: Game[] = []; games: Game[] = [];
activeGame: Game['id'] | null = null; activeGame: Game | null = null;
constructor() {} constructor() {}
@ -22,7 +22,7 @@ export class GamesBarComponent implements OnInit {
console.log(value); console.log(value);
this.games = value; this.games = value;
if (this.games.length > 0){ if (this.games.length > 0){
this.activeGame = this.games[0].title this.activeGame = this.games[0]
} }
}); });
} }