I am using Angular Datatables to show some tabular data. I have added an *ngIf
condition to the table, so that it will not be visible until the data is loaded completely. The table code looks like the following :
<table class="table" id="releaseDatatable" datatable [dtOptions]="dtOptions" [dtTrigger]="dtTrigger" *ngIf="!loading">
The loading
variable I am setting from my component and then calling this.dtTrigger.next()
. I have the following code to set loading
.
set loading(loading: boolean) {
this._loading = loading;
setTimeout(()=>{
this.dtTrigger.next();
}, 100);
}
Now for the first time, everything is working fine. But when I try to re-load the table (after edit or delete), it it is showing the following error :
ERROR ObjectUnsubscribedErrorImpl {message: "object unsubscribed", name: "ObjectUnsubscribedError"}
and this.dtTrigger
has null
as observers. How this can be fixed ? I tried to re-render the table, but it is also not working.