I am facing an error that says "Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays." I am trying to create a Notification list but I can't figure out what mistake I have made.
HTML
<ng-container *ngIf="notificationModal">
<div class="side-panel__notif-container">
<div class="side-panel__notify-header">
<span class="side-panel__usr-profile-close" (click)="clkNotifcationPnl()">
<fa-icon [icon]="faClose"></fa-icon>
</span>
<span class="side-panel__usr-noti-hdr">Notifications</span><br>
</div>
<div class="side-panel__notify-body">
<div class="side-panel__user-notif-cont">
<div class="drop-content">
<ul class="mt-2 list-group notify-contents">
<li *ngFor="let items of notify">
<div class="col-md-3 col-sm-3 col-xs-3">
<div class="notify-img">
<span [ngStyle]="{'background-image': loadProfilePic()}" class="side-panel__user-notif-img fa"></span>
</div>
</div>
<div class="col-md-9 col-sm-9 col-xs-9 pd-l0">{{items.notifyFromName}}
<p>{{items.notifyMessage}}</p>
<p class="time">{{items.notifyDate}}</p>
</div>
</li>
</ul>
</div>
</div>
</div>
</div>
</ng-container>
Component
public onClickUserNotif() {
this.headerService.isLoading = true;
return this.commonService.getNotificationList().subscribe((res) => {
if (res['status'].code === 0) {
this.headerService.isLoading = false;
let notify = res['notification']
if(notify.length > 0) {
this.notificationModal = true;
console.log(notify);
}
}
});
}
And this value is displayed when I console.log(notify)