[英]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.