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

433
Views
Using Typescript Variable to create img src

I have an array which contains a list of categories, below is an example of one category: description: "test"

[0]
    icon: "assets/images/test1"
    name: "test"
[1]
    icon: "assets/images/test2.png"
    name: "test 2"

I am trying to loop through this array and display both the category name and the icon, however, displaying the icon isn't working.

<ng-container *ngFor="let category of this.categories>
   {{category.name}}  
   <img src={{category.icon}}/>               
</ng-container>

Does anyone know how to do this? Thanks

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

I'm not an angular expert, but shouldn't you use the [] syntax for property binding?

E.g.:

<ng-container *ngFor="let category of this.categories">
   {{category.name}}  
   <img [src]="category.icon"/>               
</ng-container>

Also, you're missing a " at the end of categories.

over 4 years ago · Santiago Trujillo 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!