message: fix: Check if change detector is not destroyed
diff: import {
  Component,
  OnInit,
  + OnDestroy,
  forwardRef,
  ChangeDetectorRef,
  Input,
  @@ -41,7 +42,7 @@ const NGB_ANG_SELECT_VALUE_ACCESSOR = {
  'role': 'dropdown'
  }
  })
  -export class NgSelectComponent implements OnInit, ControlValueAccessor {
  +export class NgSelectComponent implements OnInit, OnDestroy, ControlValueAccessor {
  @ContentChild(NgOptionDirective) optionTemplateRef: TemplateRef<any>;
  @ContentChild(NgDisplayDirective) displayTemplateRef: TemplateRef<any>;
  @@ -112,6 +113,10 @@ export class NgSelectComponent implements OnInit, ControlValueAccessor {
  this.bindLabel = this.bindLabel || 'label';
  }
  + ngOnDestroy() {
  + this.changeDetectorRef.detach();
  + }
  +
  @HostListener('keydown', ['$event'])
  handleKeyDown($event: KeyboardEvent) {
  if (KeyCode[$event.which]) {
  @@ -192,8 +197,7 @@ export class NgSelectComponent implements OnInit, ControlValueAccessor {
  } else {
  this._value = null;
  }
  -
  - this.changeDetectorRef.detectChanges();
  + this.detectChanges();
  }
  registerOnChange(fn: any): void {
  @@ -278,15 +282,15 @@ export class NgSelectComponent implements OnInit, ControlValueAccessor {
  }
  showPlaceholder() {
  - return this.placeholder && !isDefined(this.value) && !this.filterValue;
  + return this.placeholder && !this.isValueSet(this.value) && !this.filterValue;
  }
  showValue() {
  - return !this.filterValue && isDefined(this.value);
  + return !this.filterValue && this.isValueSet(this.value);
  }
  showClear() {
  - return this.clearable && isDefined(this.value) && !this.isDisabled;
  + return this.clearable && this.isValueSet(this.value) && !this.isDisabled;
  }
  showFilter() {
  @@ -437,8 +441,19 @@ export class NgSelectComponent implements OnInit, ControlValueAccessor {
  private isTypeahead() {
  return this.typeahead && this.typeahead.observers.length > 0;
  }
  +
  + private detectChanges() {
  + if (!(<any>this.changeDetectorRef).destroyed) {
  + this.changeDetectorRef.detectChanges();
  + }
  }
  -function isDefined(value: any): boolean {
  + private isValueSet(value: any): boolean {
  + if (this.multiple) {
  + return !!value && value.length > 0;
  + }
  return !!value;
  }
  +}
  +
  +
  