0.0.11 • Published 9 years ago
color-pick v0.0.11
color-pick
Apply the directive to an element. When a user clicks on it, a palette will appear from which a color can be selected.
Instructions
Install locally in your project using npm:
npm install --save color-pick
Include the script in your code:
<script src="node_modules/color-pick/dist/color-pick.js"></script>
Example
- Add
tm.color-pick
as a dependency to your app module:angular.module('myApp', ['tm.color-pick'])
- Expose your function into the scope of the directive:
angular.module('myApp') .run(function ($rootScope) { $rootScope.setBg = function (color) { document.body.style.backgroundColor = color; }; });
- Add the directive to your html:
<div ng-app="myApp"> <input type="button" value="Select a background color" color-pick="setBg(color)"> </div>
- Click on the button, select a color, and watch the background change.