ruhley / angular-color-picker

Vanilla AngularJS Color Picker Directive with no requirement on jQuery
http://ruhley.github.io/angular-color-picker/
MIT License
165 stars 78 forks source link

model does not get initialized correctly #170

Closed bipinshashi closed 7 years ago

bipinshashi commented 7 years ago

The color picker swatch shows the right color, but the input field is wrong. It gets updated to the right value when you click on the field and focus it.

ruhley commented 7 years ago

@bipinshashi Can you give me more details on what your problem is?

bipinshashi commented 7 years ago

it seems like the input model does not get updated on page load with the right color - for example if the color was rgb(255,0,0), on page load the color swatch would be red but the input would be empty. If you focus the input field, it gets updated to red.

It sounds like there is a digest cycle not being triggered properly. I reverted back to 3.3.0 and it seems to work.

ruhley commented 7 years ago

@bipinshashi I cannot replicate this problem with a basic color picker. Maybe there is something in the options that you are passing in. Can you setup a plunker or something showing the issue?

ruhley commented 7 years ago

@bipinshashi The problem occurred anytime the ngModel was programmatically changed after the color picker had been initialized. So if you were loading the color value from an ajax call then it could be set after the color picker was initialized.

Fixed in commit aa8f553 and released in v3.4.6