Use of HttpClient in angular

0

I have a problem:

This is my service code

import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { HttpErrorResponse } from '@angular/common/http';


@Injectable()
export class PhonesService {
  //esta es la ruta del archivo json con la data
  private urlPhonesData: string ='assets/data/phones.json';


  constructor(private _httpService: HttpClient) {

    console.log("Servicio de phones listo para usarse!!!!!");

  }

  //esta funcion hace el llamado a la data del archivo Json que tiene toda la informacion de los telefonos
  getPhones(){

    //el servicio _httpService nos regresa un observable  por lo que es un tipo de objeto anonimo el cual con la interface Phone le especificamos la forma en la que debe de regresar los datos al componente
    return this._httpService.get<Phone>(this.urlPhonesData);


  }

  getPhone(idx:string){

    //return this.phones[idx];

    console.log("Estes es el id que se recibe como parametro " + idx);

    return this._httpService.get<Phone>(this.urlPhonesData);
  }

export interface Phone{
  id:string,
  marca:string;
  box:string;
  metodo:string;
  detalles:string;
  timeunlock:string;
  img:string;
};

In the part of the getPhone () function I would like to show only the data that matches the team Id, but I do not know how to put that in that function. Since I have a component which I want in the view to show only the data with the corresponding Id.

    
asked by Socrasky Salamanca 26.07.2018 в 08:46
source

0 answers