【发布时间】:2018-03-21 12:36:44
【问题描述】:
ObjectUnsubscribedError: object unsubscribed,有时(不是每次)在文本框中输入任何值时
HTML
<input #gb type="text" pInputText class="ui-widget ui-text"
[(ngModel)]="gb.value" (ngModelChange)="clearFilter(gb.value)" placeholder="Find" />
component.ts
clearFilter(newValue) {
this.infomessage = [];
this.errormessage = [];
this.isDelete = false;
this.isDefaultLoad = false;
if (this.oldFilterText === '' && newValue === '') {
return false;
}
this.oldFilterText = newValue;
if (this._configuration.isNullOrEmptyOrUndefined(newValue)) {
this.sortField = '';
if (!this._configuration.isNullOrEmptyOrUndefined(this.dataTable.sortField)) {
this.sortField = this.dataTable.sortField;
}
this.dataTable.reset();
this.tempFilteredRecords = [];
this.getApprovalTypelist();
this.dataTable.sortField = this.sortField;
this.dataTable.sortMode = 'single';
this.dataTable.sortOrder = this.sortOrder;
}
}
我的代码运行良好!但有时在文本框中输入时会出错。此外,clearFilter 在收到此错误后也不会触发。
错误:ObjectUnsubscribedError:对象取消订阅
我已经尝试过这个(但我不知道下面的这些链接是否与我的缺陷相关)下面的讨论
Angular 2 object unsubscribed error
ObjectUnsubscribedError when trying to prevent subscribing twice
Exception: ObjectUnsubscribedError when working with Observables with RxJS and Angular2
ObjectUnsubscribedError when trying to prevent subscribing twice
但一切都对我没有帮助。请带我摆脱这个不可预知的缺陷:(
【问题讨论】:
标签: javascript html angular typescript observable