Skip to content

Commit

Permalink
fix(base-input): first ngModel update is not dispatched
Browse files Browse the repository at this point in the history
  • Loading branch information
manucorporat committed Apr 27, 2017
1 parent d24c4f4 commit 505d27a
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/util/base-input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ export class BaseInput<T> extends Ion implements CommonInput<T> {
_disabled: boolean = false;
_debouncer: TimeoutDebouncer = new TimeoutDebouncer(0);
_init: boolean = false;
_initModel: boolean = false;

id: string;

/**
Expand Down Expand Up @@ -122,8 +124,14 @@ export class BaseInput<T> extends Ion implements CommonInput<T> {
*/
writeValue(val: any) {
if (this._writeValue(val)) {
this._fireIonChange();
if (this._initModel) {
this._fireIonChange();
} else if (this._init) {
// ngModel fires the first time too late, we need to skip the first ngModel update
this._initModel = true;
}
}

}

/**
Expand Down Expand Up @@ -161,6 +169,7 @@ export class BaseInput<T> extends Ion implements CommonInput<T> {
this._debouncer.debounce(() => {
assert(NgZone.isInAngularZone(), 'IonChange: should be zoned');
this.ionChange.emit(this._inputChangeEvent());
this._initModel = true;
});
}
}
Expand Down

1 comment on commit 505d27a

@manucorporat
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@VSMax this was the commit that fixed #8070

Please sign in to comment.