Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

182
Vistas
Searching in in-memory DB in Angular

I have an in-memory DB in angular

createDb(){
    let Data= [
      {id:1 , ProviderCode: '9W-', ProviderName: 'Jet Airways', ProviderType: 'Domestic' },
      {id:2 , ProviderCode: 'EK-', ProviderName: 'Emirates', ProviderType: 'International' },
    ];
    return {Data};
  }

and I have specified CRUD operations in separate service

 public getAllAirlines(){ 
       return this.httpClient.get(this.SERVER_URL + 'Data');
  }

  public getAirlines(ProviderType: String){
       return this.httpClient.get(`${this.SERVER_URL + 'Data'}/${ProviderType}`); 
  }
  public createAirlines(data: {ProviderCode: String, ProviderName: String, ProviderType: String}){
      return this.httpClient.post(`${this.SERVER_URL + 'Data'}`,data );
  }

  public deleteAirlines(AirlineId: String){
      return this.httpClient.delete(`${this.SERVER_URL + 'Data'}/${AirlineId}`);
  }
  public updateAirlines (data: {ProviderCode: String, ProviderName: String, ProviderType: String}) {
    return this.httpClient.put(`${this.SERVER_URL + 'Data'}/${data.ProviderCode}/${data.ProviderType}`, data);
  }

I have a Delete airline component, which has a form having details as ProviderCode and ProviderType to delete. To delete the record I need to retrieve the ID from the DB and I am unable to do that. Same case with update functionality. Please suggest me ways to do that.

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

This function:

getAllAirlines(){ 
  return this.httpClient.get(this.SERVER_URL + 'Data');
}

Will return you an observable.

In your component you can subscribe to it and that will get you all the Airline objects with their id.

Writing the function fullout might help you with understanding:

getAllAirlines(): Observable<Airline[]>{ 
  return this.httpClient.get<Airline[]>(this.SERVER_URL + 'Data');
}

Let me also give an example of how to get the data from this request.

In your "delete-airline.component.ts":

airlines: Airline[] = []
...
constructor(
  private separateService: SeparateService
) { }

ngOnInit():void {
  this.separateService.getAllAirlines().subscibe(
    data => this.airlines = data
  )
}

Then you can just loop over the items in your airlines array and use their id values...

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda