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

131
Views
Why can I not get output in my html from ngFor?

I have a simple local JSON. It's

{ list: [{value: value, value: value ...},{},{},{},{},{},{},{}]},

so the JSON should be valid right? I just can't seem to get it out to the ngFor in my html... Is there any way to log what is output in the ngFor in the html? .. like inline console.log or something? Or maybe I'm doing something else wrong. here is an excerpt of my code:

local JSON formatted like (has actual data of course..):

{ list: [{value: value, value: value ...},{},{},{},{},{},{},{}]}

list-typings.d.ts (in same folder as list.json - is this correct? Should I import it?):

declare module "*.json" {
  const value: any;
  export interface list {
    id: number;
    name: string;
    age: number;
    interests: string;
  }
}

My table.component.ts:

import { Component, OnInit } from "@angular/core";
import list from "./../../assets/list.json";

console.log(list);

@Component({
  selector: "app-table",
  templateUrl: "./table.component.html",
  styleUrls: ["./table.component.css"],
})
export class TableComponent implements OnInit {
  listList: any = list.arrayKey;

  constructor() {
    console.log(this.arrayKey);
  }

  ngOnInit(): void {}
}

Now I should be able to do *ngFor="let list of listList" and the get all {{list.name}} inline in my html right? I've tried so many variants, but I can not get any output...

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Your template would look like this:

<ng-container *ngFor="let list of listList">
    <span>{{list.someKey}}</span>
</ng-container>

Also, make sure that listList is declared in your component. It should be an array and public.

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!