Angular Color Selectbox Directive
bower install angular-color-selectbox --save-
Include files
- Bower
<link rel="stylesheet" href="bower_components/angular-color-selectbox/dist/angularjs-color-selectbox.min.css" />
<script src="bower_components/angular-color-selectbox/dist/angularjs-color-selectbox.min.js"></script>- Add the module to your app
angular.module('app', ['color.selectbox']);- Include in your view
<color-selectbox onselect="vm.onSelectColor"></color-selectbox>- onselect: function to be executed when color is chosen.
- item: data for use by controller for the directive
- position: put the menu to right or left of button, default is 'left'
- color: color of button
<color-selectbox
onselect="vm.onSelectColor"
item="myItem"
position="'right'"
color="myColor"
></color-picker>There is a global variable to set the size. This is set with a global variable rather than a setting on the directive, because the menu is created just once per page. Size should be 16, 25 (default) or 36.
cpSize = 16;The default pallette is a fairly random set of colors listed in src/scripts/color-selectbox.directive.js. You'll probably want to edit the pallette list to suit your requirements. After editing, run
grunt buildto regenerate the files in the /dist folder.
- angularjs (v1.3 and higher)
- lodash
- jquery
- fontAwesome