Skip to content

Commit

Permalink
fix: ViewDestroyedError: detectChanges
Browse files Browse the repository at this point in the history
  • Loading branch information
edskeizer authored Nov 27, 2019
1 parent a21bdfb commit a4de144
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/app/lib/ngx-select/ngx-select.component.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
AfterContentChecked, DoCheck, Input, Output, ViewChild,
Component, ElementRef, EventEmitter, forwardRef, HostListener, IterableDiffer, IterableDiffers, ChangeDetectorRef, ContentChild,
TemplateRef, Optional, Inject, InjectionToken, ChangeDetectionStrategy
TemplateRef, Optional, Inject, InjectionToken, ChangeDetectionStrategy, OnDestroy
} from '@angular/core';
import {ControlValueAccessor, NG_VALUE_ACCESSOR} from '@angular/forms';
import {DomSanitizer, SafeHtml} from '@angular/platform-browser';
Expand Down Expand Up @@ -44,7 +44,7 @@ function propertyExists(obj: object, propertyName: string) {
}
]
})
export class NgxSelectComponent implements INgxSelectOptions, ControlValueAccessor, DoCheck, AfterContentChecked {
export class NgxSelectComponent implements INgxSelectOptions, ControlValueAccessor, DoCheck, AfterContentChecked, OnDestroy {
@Input() public items: any[];
@Input() public optionValueField = 'id';
@Input() public optionTextField = 'text';
Expand Down Expand Up @@ -362,6 +362,10 @@ export class NgxSelectComponent implements INgxSelectOptions, ControlValueAccess

}
}

public ngOnDestroy(): void {
this.cd.detach();
}

public canClearNotMultiple(): boolean {
return this.allowClear && !!this.subjOptionsSelected.value.length &&
Expand Down

0 comments on commit a4de144

Please sign in to comment.