Свойство «include» отсутствует в TypeScript - PullRequest
0 голосов
/ 16 декабря 2018

Я хочу сделать маршрутизацию и получить данные с моего локального хоста.Я проверил на консоли данные вышли, но я не могу отобразить данные вообще.И я получил это сообщение об ошибке на терминале

ERROR in src/app/detail/detail.component.ts(19,9): error TS2322: Type 'IGames' is not assignable to type 'IGames[]'.
  Property 'includes' is missing in type 'IGames'.

, это мой detail.component.ts

import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { GamesService } from '../games.service';
import { IGames } from '../games';

@Component({
  selector: 'app-detail',
  templateUrl: './detail.component.html',
  styleUrls: ['./detail.component.css']
})
export class DetailComponent implements OnInit {
  id:string='';
  game:IGames[]=[];
  constructor(public route:ActivatedRoute, private gs:GamesService) { }
  ngOnInit() {
    this.id = this.route.snapshot.params['id'];
    this.gs.getGamesDetail(this.id).subscribe(
      (data)=>{
        this.game=data;
        console.log(data);
      }
    );
  }
}

, это мой сервис

getGamesDetail (id:string):Observable<IGames> {
    let body = new HttpParams();
    body = body.set('id', id);
    return this.http.post<IGames>("http://localhost/pmn/uas/getgamesdetail.php", body);
  }
...