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
The 'Object' type is assignable to very few other types

I have an angular 12 application and I have a service call which is returning an Object. I need to iterate through the object and display the values in the HTML. The problem is that I need to use strict typescript types. So "any" is not allowed. Here is my working code and this works fine if I declare files: any; But I need to use strict typescript types so "any" is not allowed.

SERVICE CALL:

public getUserUploadedFileName() {
    return this.httpClient.get(this.url);
}

TS FILE:

files: any;
this._myService
        .getUserUploadedFileName()
        .subscribe((data) => {
            this.files = data;
        }); 

HTML :

<div *ngFor="let file of files">
        {{ file }} </div>
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

You could get the values by:

this._myService
        .getUserUploadedFileName()
        .subscribe((data) => {
            this.files = Object.values(data);
        }); 
about 4 years ago · Juan Pablo Isaza Denunciar

0

After imports section declare an interface fit your data properties:

//imports .....

export interface IResponseData {
property1:string;
property2:number;
property3:string;

}
files: Array<IResponseData>;
    this._myService
            .getUserUploadedFileName()
            .subscribe((data:Array<IResponseData>) => {
                this.files = data;
            }); 
about 4 years ago · Juan Pablo Isaza 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