mirror of
https://github.com/Wessel/nhl-setgame.git
synced 2026-06-08 14:18:05 +02:00
chore(frontend): Update dependency injection to use latest style
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import { Router } from '@angular/router';
|
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 { UserDataService } from '../../service/user/user-data.service';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
|
|
||||||
@@ -11,7 +11,10 @@ import { CommonModule } from '@angular/common';
|
|||||||
})
|
})
|
||||||
export class GameListComponent {
|
export class GameListComponent {
|
||||||
games: { id: number, startedAt: Date, finishedAt: Date | null, fails: number, hand: any[], deck: any[] }[] | undefined;
|
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() {
|
async getGames() {
|
||||||
this.games = await this.userService.getGames();
|
this.games = await this.userService.getGames();
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Component } from '@angular/core';
|
import { Component, inject } from '@angular/core';
|
||||||
import { GameService } from '../../service/game/game.service';
|
import { GameService } from '../../service/game/game.service';
|
||||||
import { Card } from '../models/card';
|
import { Card } from '../models/card';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
@@ -15,8 +15,11 @@ import { ActivatedRoute, UrlSegment, Router } from '@angular/router';
|
|||||||
export class GameComponent {
|
export class GameComponent {
|
||||||
gameId: string = '';
|
gameId: string = '';
|
||||||
hint: Card[] = []
|
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.route.params.subscribe(params => {
|
||||||
this.gameId = params['id'];
|
this.gameId = params['id'];
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { Card, toCard } from '../../app/models/card';
|
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';
|
import axios from 'axios';
|
||||||
|
|
||||||
@Injectable({ providedIn: 'root' })
|
@Injectable({ providedIn: 'root' })
|
||||||
|
|||||||
Reference in New Issue
Block a user