An AngularJS directive that turns a select (multi or single) into a clickable palette of colors.
This is different from other color pickers out there because it limits the available colors to those listed in the select box.
It's also designed to work first as a standard select element, then as a select element with an ngModel attached, then as the actual color select widget.
By default, a single color can be selected; use the select
element's multiple
attribute to indicate more than one color may be selected.
This directive looks for colors in the following locations, in this order, in each color's option
element:
data-color
attributevalue
attribute
A color value can be either a named HTML color or a hex code (no pound sign necessary)
<select name="color" data-color-select>
<option value="">- Select -</option>
<option value="red">Red</option>
<option value="orange">Orange</option>
<option value="yellow">Yellow</option>
</select>
<select name="color" multiple="multiple" data-color-select>
<option value="">- Select -</option>
<option value="f00">Red</option>
<option value="f60">Orange</option>
<option value="ff0">Yellow</option>
</select>
<select name="color" data-color-select>
<option value="">- Select -</option>
<option value="stop" data-color="f00">Stop</option>
<option value="caution" data-color="ff0">Caution</option>
<option value="go" data-color="0f0">Go</option>
</select>
Karen Ziv [email protected]