Skip to content

Commit

Permalink
fix: ERROR Error: ExpressionChangedAfterItHasBeenCheckedError: Expres…
Browse files Browse the repository at this point in the history
…sion has changed after it was checked. Previous value: 'open show: 58'. Current value: 'open show: false'.

         at viewDebugError (core.js:9758)
         at expressionChangedAfterItHasBeenCheckedError (core.js:9736)
         at checkBindingNoChanges (core.js:9903)
         at checkNoChangesNodeInline (core.js:13953)
         at checkNoChangesNode (core.js:13925)
         at debugCheckNoChangesNode (core.js:14754)
         at debugCheckDirectivesFn (core.js:14656)
         at Object.eval [as updateDirectives] (NgxSelectComponent.html:2)
         at Object.debugUpdateDirectives [as updateDirectives] (core.js:14638)
         at checkNoChangesView (core.js:13763)
  • Loading branch information
optimistex committed Feb 11, 2018
1 parent ac92543 commit 32ba202
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/app/lib/ngx-select/ngx-select.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {
AfterContentChecked, DoCheck, Input, Output, ViewChild,
Component, ElementRef, EventEmitter, forwardRef, HostListener, IterableDiffer, IterableDiffers
Component, ElementRef, EventEmitter, forwardRef, HostListener, IterableDiffer, IterableDiffers, ChangeDetectorRef
} from '@angular/core';
import {ControlValueAccessor, NG_VALUE_ACCESSOR} from '@angular/forms';
import {DomSanitizer, SafeHtml} from '@angular/platform-browser';
Expand Down Expand Up @@ -98,7 +98,7 @@ export class NgxSelectComponent implements ControlValueAccessor, DoCheck, AfterC
private _focusToInput = false;
private isFocused = false;

constructor(private sanitizer: DomSanitizer, iterableDiffers: IterableDiffers) {
constructor(iterableDiffers: IterableDiffers, private sanitizer: DomSanitizer, private cd: ChangeDetectorRef) {
// differs
this.itemsDiffer = iterableDiffers.find([]).create<any>(null);
this.defaultValueDiffer = iterableDiffers.find([]).create<any>(null);
Expand Down Expand Up @@ -184,6 +184,7 @@ export class NgxSelectComponent implements ControlValueAccessor, DoCheck, AfterC
if (event.clickedSelectComponent !== this) {
if (this.optionsOpened) {
this.optionsClose();
this.cd.detectChanges(); // fix error because of delay between different events
}
if (this.isFocused) {
this.isFocused = false;
Expand Down

0 comments on commit 32ba202

Please sign in to comment.