Skip to content

Commit 505d27a

Browse files
committed
fix(base-input): first ngModel update is not dispatched
1 parent d24c4f4 commit 505d27a

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/util/base-input.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ export class BaseInput<T> extends Ion implements CommonInput<T> {
3838
_disabled: boolean = false;
3939
_debouncer: TimeoutDebouncer = new TimeoutDebouncer(0);
4040
_init: boolean = false;
41+
_initModel: boolean = false;
42+
4143
id: string;
4244

4345
/**
@@ -122,8 +124,14 @@ export class BaseInput<T> extends Ion implements CommonInput<T> {
122124
*/
123125
writeValue(val: any) {
124126
if (this._writeValue(val)) {
125-
this._fireIonChange();
127+
if (this._initModel) {
128+
this._fireIonChange();
129+
} else if (this._init) {
130+
// ngModel fires the first time too late, we need to skip the first ngModel update
131+
this._initModel = true;
132+
}
126133
}
134+
127135
}
128136

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

0 commit comments

Comments
 (0)