Просмотр исходного кода

print single objects in gameHTML

nafis nibir 8 лет назад
Родитель
Сommit
5c467ff49b

+ 4
- 4
client/src/pages/games/games.html Просмотреть файл

@@ -6,10 +6,10 @@
6 6
 
7 7
 <ion-content padding>
8 8
   <ion-list>
9
-    <ion-item *ngFor="let game of games">
10
-      <h2>{{game.title}}</h2>
11
-      <h3>{{ game.studio }}</h3>
12
-      <h4>{{ game.platform }}</h4>
9
+    <ion-item >
10
+      <h2>{{singleGame.title}}</h2>
11
+      <h3>{{ singleGame.studio }}</h3>
12
+      <h4>{{ singleGame.platform }}</h4>
13 13
     </ion-item>
14 14
   </ion-list>
15 15
 </ion-content>

+ 4
- 2
client/src/pages/games/games.ts Просмотреть файл

@@ -16,6 +16,7 @@ import {GameService} from "../../providers/game-service";
16 16
 })
17 17
 export class GamesPage {
18 18
   private games: Array<any>;
19
+  private singleGame: any ={};
19 20
 
20 21
   constructor(public navCtrl: NavController, public navParams: NavParams,
21 22
               public gameService: GameService) {
@@ -23,8 +24,9 @@ export class GamesPage {
23 24
 
24 25
   ionViewDidLoad() {
25 26
     //setInterval(() => {
26
-      this.gameService.getGames().subscribe(games => {
27
-        this.games = games;
27
+      this.gameService.getGame(3).subscribe(games => {
28
+        console.log(games)
29
+        this.singleGame= games;
28 30
       })
29 31
     //}, 100000);
30 32
   }

+ 4
- 0
client/src/providers/game-service.ts Просмотреть файл

@@ -13,4 +13,8 @@ export class GameService{
13 13
   getGames(): Observable<any> {
14 14
     return this.http.get(this.GAME_API);
15 15
   }
16
+
17
+  getGame(id: number): Observable<any> {
18
+    return this.http.get(this.GAME_API + "/id/" + id);
19
+  }
16 20
 }