[英]Angular datatable unsubscription error while closing ngx-bootstrap modal
我正在使用Angular DataTable和ngx-bootstrap模式。 當我關閉模態時,數據表會拋出取消訂閱錯誤,並且數據表不會初始化。 我嘗試了使用重新渲染,unsubsc的多種解決方法 在onHide事件上看到它並沒有解決。 如果有人知道如何解決它,請幫助
this.subscriptions.push(
this.modalService.onHidden.subscribe((reason: string) => {
alert('Hidden');
this.dtElement.dtInstance.then((dtInstance: DataTables.Api) => {
alert('Destroying..')
//Clear the table first
dtInstance.clear();
// Destroy the table
dtInstance.destroy();
})
this.dtTriggerFreshness.unsubscribe();
})
);
有一個上下文錯誤。
let trigger=this.dtTriggerFreshness;
let dtElementVar= this.dtElement;
let modalServiceVar=this.modalService;
this.subscriptions.push(
modalService.onHidden.subscribe((reason: string) => {
alert('Hidden');
dtElementVar.dtInstance.then((dtInstance: DataTables.Api) => {
alert('Destroying..')
//Clear the table first
dtInstance.clear();
// Destroy the table
dtInstance.destroy();
trigger.dtTriggerFreshness.unsubscribe();
})
})
);
現在它必須工作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.