Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

176
Views
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 answers
Answer question

0

You could get the values by:

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

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!