"TypeError: Cannot read properties of undefined (reading 'onDestroy')" while using observable with NgFor and the Async Pipe
I'm trying to display a list of jobs, the code looks like
loadJob() {
let query = { pageNo: this.pageNo, title: this.searchParam.title, location: this.searchParam.location, industry:this.searchParam.industry }
this.store.dispatch(InitJobComponent({query}));
this.jobs$ = this.store.pipe(
select(getJobState)
);
this.jobs$.subscribe((jobs) => {
if (jobs && jobs.data && jobs.data.length>0) {
this.currentJob = jobs.data[0];
this.checkSaveStatus(this.currentJob);
this.trustedUrl = this.sanitizer.bypassSecurityTrustResourceUrl(this.currentJob.file);
}
});
}
<div *ngIf="(jobs$ | async) as jobs" class="page-wrapper job-list">
<div class="no-results" *ngIf="jobs.totalCount == 0">
<h3>No results found.</h3>
</div>
<nz-layout *ngIf="jobs.totalCount > 0" class="content">
<nz-sider class="side-bar-job-list">
<ul class="jobs" nz-menu nzMode="inline">
<li nz-menu-item *ngFor="let job of jobs.data; let i=index" (click)="details(job);">
<!-- whatever the code is to display the list -->
</li>
</ul>
<nz-pagination [nzPageIndex]="pageNo" (nzPageIndexChange)="paginate($event);" [nzTotal]="jobs.totalCount">
</nz-pagination>
</nz-sider>
</nz-layout>
</div>
I get the error ERROR TypeError: Cannot read properties of undefined (reading 'onDestroy')
where I'm trying to use *ngFor
. I can't figure out why this is happening, please help.
Comments
Post a Comment