2
0
Fork 0
mirror of https://github.com/AIR-EISTI/hades.git synced 2025-04-09 17:35:14 +02:00

Moving game service and model in right directory

This commit is contained in:
echo 2018-10-18 11:30:41 +02:00
parent 03113fdb19
commit f8822386fc
6 changed files with 32 additions and 32 deletions

View file

@ -1,7 +1,7 @@
import { Component, OnInit,Input } from '@angular/core';
import { Component, OnInit, Input } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { Game } from '../game';
import { GameService } from '../game.service';
import { Game } from '../models/game';
import { GameService } from '../services/game.service';
@Component({
@ -14,7 +14,7 @@ export class GameDetailComponent implements OnInit {
game : Game;
gameName : string;
constructor(private route: ActivatedRoute,public gameService: GameService) {
constructor(private route: ActivatedRoute,public gameService: GameService) {
}
ngOnInit() {
@ -22,7 +22,7 @@ export class GameDetailComponent implements OnInit {
}
getGame(): void {
this.gameName = this.route.snapshot.paramMap.get('name');
this.gameService.getOneGame(this.gameName).subscribe(

View file

@ -1,23 +0,0 @@
import { HttpClient } from '@angular/common/http';
import { Observable , of} from 'rxjs'
import { Injectable } from '@angular/core';
import { Game } from './game';
@Injectable({
providedIn: 'root'
})
export class GameService {
constructor(private http: HttpClient) {
}
getGames() : Observable<Game[]>{
return this.http.get<Game[]>("http://localhost:4200/api/games/");
}
getOneGame(game_name) : Observable<Game>{
return this.http.get<Game>("http://localhost:4200/api/games/"+game_name);
}
}

View file

@ -1,6 +1,6 @@
import { Component, OnInit } from '@angular/core';
import { Game } from '../game';
import { GameService } from '../game.service';
import { Game } from '../models/game';
import { GameService } from '../services/game.service';
@ -19,12 +19,12 @@ export class GamesComponent implements OnInit {
this.getGames()
}
getGames(): void {
this.gameService.getGames().subscribe(
games => this.games = games,
error => console.log(error)
)
}
}

View file

@ -0,0 +1,23 @@
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
import { Injectable } from '@angular/core';
import { Game } from '../models/game';
@Injectable({
providedIn: 'root'
})
export class GameService {
constructor(private http: HttpClient) {
}
getGames() : Observable<Game[]>{
return this.http.get<Game[]>('/api/games/');
}
getOneGame(gameName) : Observable<Game>{
return this.http.get<Game>('/api/games/' + gameName);
}
}