chore(frontend): Update dependency injection to use latest style

This commit is contained in:
2025-03-18 12:30:42 +00:00
parent a09b5676f6
commit baeadaa1ce
3 changed files with 11 additions and 4 deletions

View File

@@ -1,5 +1,5 @@
import { Router } from '@angular/router';
import { Component } from '@angular/core';
import { Component, inject } from '@angular/core';
import { UserDataService } from '../../service/user/user-data.service';
import { CommonModule } from '@angular/common';
@@ -11,7 +11,10 @@ import { CommonModule } from '@angular/common';
})
export class GameListComponent {
games: { id: number, startedAt: Date, finishedAt: Date | null, fails: number, hand: any[], deck: any[] }[] | undefined;
constructor(public userService: UserDataService, private router: Router) { this.getGames() }
userService: UserDataService = inject(UserDataService);
router: Router = inject(Router);
constructor() { this.getGames() }
async getGames() {
this.games = await this.userService.getGames();

View File

@@ -1,4 +1,4 @@
import { Component } from '@angular/core';
import { Component, inject } from '@angular/core';
import { GameService } from '../../service/game/game.service';
import { Card } from '../models/card';
import { CommonModule } from '@angular/common';
@@ -15,8 +15,11 @@ import { ActivatedRoute, UrlSegment, Router } from '@angular/router';
export class GameComponent {
gameId: string = '';
hint: Card[] = []
gameService: GameService = inject(GameService);
route: ActivatedRoute = inject(ActivatedRoute);
router: Router = inject(Router);
constructor(public gameService: GameService, private route: ActivatedRoute, private router: Router) {
constructor() {
this.route.params.subscribe(params => {
this.gameId = params['id'];

View File

@@ -1,5 +1,6 @@
import { Injectable } from '@angular/core';
import { Card, toCard } from '../../app/models/card';
// todo: Rewrite to use angular http client instead of axios, supports always sending tokens
import axios from 'axios';
@Injectable({ providedIn: 'root' })