Created
May 28, 2014 22:11
-
-
Save ericz/a937db66ce29d02e5703 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # | |
| # colorPicker | |
| # | |
| # Allows the user to select a color from available `colors`, and emits the selected color. | |
| # | |
| # Attributes: | |
| # currColor: The currently selected color, as a hex string e.g. '#ffffff' | |
| # colors: An array of available colors, as hex strings | |
| # visible: true | false Show or hide the color selector | |
| # | |
| # Events: | |
| # color-change ({color: '#ffffff'}) -> emits an object containing the `currColor` hex string when the currColor changes | |
| # | |
| # Example: | |
| ### | |
| <color-picker | |
| colors="colors" | |
| curr-color="currColor" | |
| visible="showColorPicker"> | |
| </color-picker> | |
| ### | |
| module.exports = (app) -> | |
| app.directive('colorPicker', ($rootScope) -> | |
| component = | |
| restrict: 'E' | |
| scope: | |
| colors: '=' | |
| currColor: '=' | |
| visible: '=' | |
| templateUrl: '/views/colorPicker.html' | |
| controller: ($rootScope, $scope) -> | |
| $scope.changeColor = (color) -> | |
| $scope.currColor = color | |
| $rootScope.$emit('color-change', {color: $scope.currColor}) | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment