ObjectUnsubscribedError: object unsubscribed , when sometime(not every time) entering any value in text box
<input #gb type="text" pInputText class="ui-widget ui-text"
[(ngModel)]="gb.value" (ngModelChange)="clearFilter(gb.value)" placeholder="Find" />
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;
}
}
My code working good! but Sometime am getting a error when type in the text box. Also clearFilter
does not fire after getting this error.
error : ObjectUnsubscribedError: object unsubscribed
I have tried this(But I don't know these below links related with my defects or not) below discussions
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
But everything does not helps to me. Kindly take me out of this unpredictable defect :(
Finally I got the answer, I have just unsubscribe the onFilter()
event by using this below code
this.dataTable.onFilter.unsubscribe();
Thanks for the views!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.