@@ -34,8 +34,6 @@ export default class AngularColorPickerController {
3434 this . ngModelOptions = this . $scope . control [ 0 ] . $options . $$options ;
3535 }
3636
37- this . internalNgModel = this . ngModelOptions . getterSetter ? this . ngModel ( ) : this . ngModel ;
38-
3937 // browser variables
4038 this . chrome = Boolean ( window . chrome ) ;
4139 let _android_version = window . navigator . userAgent . match ( / A n d r o i d \s ( [ 0 - 9 \. ] * ) / i) ;
@@ -98,7 +96,7 @@ export default class AngularColorPickerController {
9896
9997 // ngModel
10098
101- this . $scope . $watch ( 'AngularColorPickerController.internalNgModel' , this . watchNgModel . bind ( this ) ) ;
99+ this . $scope . $watch ( 'AngularColorPickerController.internalNgModel' , this . watchInternalNgModel . bind ( this ) ) ;
102100 this . $scope . $watch ( 'AngularColorPickerController.ngModel' , this . watchNgModel . bind ( this ) ) ;
103101
104102 // options
@@ -174,6 +172,16 @@ export default class AngularColorPickerController {
174172 } ) ;
175173 }
176174
175+ watchInternalNgModel ( newValue , oldValue ) {
176+ // the mouse is still moving so don't do anything yet
177+ if ( this . colorMouse ) {
178+ return ;
179+ }
180+
181+ // calculate and set color values
182+ this . watchNgModelSet ( newValue ) ;
183+ }
184+
177185 /** Triggered on change to internal or external ngModel value */
178186 watchNgModel ( newValue , oldValue ) {
179187 // set initial value if not already set
@@ -184,6 +192,9 @@ export default class AngularColorPickerController {
184192 // sets the field to pristine or dirty for angular
185193 this . checkDirty ( newValue ) ;
186194
195+ // update the internal model from external model
196+ this . internalNgModel = this . ngModelOptions . getterSetter ? this . ngModel ( ) : this . ngModel ;
197+
187198 // the mouse is still moving so don't do anything yet
188199 if ( this . colorMouse ) {
189200 return ;
0 commit comments