1

I am using angular-spectrum-colorpicker to use spectrum.js in my code. It works basically fine except the value is not initialized with model. The following is the settings I used:

<spectrum-colorpicker ng-model="backgroundColor"
                        options="{
                                 flat: true,
                                 preferredFormat: 'hex',
                                 showInput: true,
                                 showButtons: false,
                                 clickoutFiresChange: true,
                                 }">
</spectrum-colorpicker>

And here is a jsbin to demostrate the problem. You can see that it works fine except the color is not correctly initialized at the beginning. You may reproduce the error by toggling the output pannel.

JSBin

What have I missed or is it a bug that I should report on github?

1 Answer 1

1

How about passing color by option?

  <spectrum-colorpicker ng-model="backgroundColor"
                        options="{
                                 color: backgroundColor,
                                 flat: true,
                                 preferredFormat: 'hex',
                                 showInput: true,
                                 showButtons: false,
                                 clickoutFiresChange: true,
                                 }">
Sign up to request clarification or add additional context in comments.

2 Comments

It works, but better try with the jsbin I provided before you answer? It is odd to start an answer with "How about"
@cytsunny Well, I have tried it in jsbin. Next time I will use another phrase.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.