Abid
Abid

Reputation: 127

unable to fetch data using ngFor in Angular component

I am trying to show the data in div using ngFor it showing supporting object error and i am passing the data in ID format.

Data are not showing in frontend but in console getting data without any errors.

<div *ngFor="let item of status_history">
    <span>{{item?.data?.invoice_status?.data?.status}}</span>
</div>

 status_history: any = [];

constructer(){

this._activatedRoute.params.forEach((params: Params) => {
  this.invoice_id = params['id'];
});
}

ngOnInit() {
  this.getStatusHistory(this.invoice_id);
}

getStatusHistory(id) {
this._httpService.getInvoiceHistoryStatus(id).subscribe((result) => {
  this.status_history = result.data;
  console.log(this.status_history);
});

getInvoiceHistoryStatus(id: string) {
const url = `${API_LIST.INVOICE_V2.HISTORY_STATUS}${id}`;
return this.http.get(url);
}

enter image description here

Upvotes: 0

Views: 44

Answers (1)

StPaulis
StPaulis

Reputation: 2916

Inside your *ngFor it should be:

<span>{{item?.invoice_status?.data[0]?.status}}</span>

There is no data inside your item

Upvotes: 1

Related Questions