Navneet Singh
Navneet Singh

Reputation: 3

Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays in angular

when I try to update data based on the id unable to iterate data in form fields, please find the screenshots for more details

Error Preview

Upvotes: 0

Views: 46

Answers (1)

Tony
Tony

Reputation: 910

to iterate through ngFor data must be in form of an array

html.component.html

<div *ngFor = "let title of fetchData">
  {{title.title}} -- {{title.description}} -- {{title.tagline}} {{title.date}}
</div>

html.component.ts

import { Component } from '@angular/core';
@Component({
  selector: 'my-app',
  templateUrl: './app.component.html',
  styleUrls: [ './app.component.css' ]
})
export class AppComponent  {

  fetchData = [{"title":"saurabh","description":"dd","tagline":"tt","date":"dd"},{"title":"aman","description":"dd","tagline":"tt","date":"dd"},{"title":"jessica","description":"dd","tagline":"tt","date":"dd"},{"title":"rosh","description":"dd","tagline":"tt","date":"dd"}];


}

Upvotes: 1

Related Questions