forked from joujiahe/ng-color-picker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcolor-picker.js
35 lines (32 loc) · 941 Bytes
/
color-picker.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
angular.module('ngColorPicker', [])
.directive('ngColorPicker', function() {
var defaultColors = [
'#7bd148',
'#5484ed',
'#a4bdfc',
'#46d6db',
'#7ae7bf',
'#51b749',
'#fbd75b',
'#ffb878',
'#ff887c',
'#dc2127',
'#dbadff',
'#e1e1e1'
];
return {
scope: {
selected: '=',
customizedColors: '=colors'
},
restrict: 'AE',
template: '<ul><li ng-repeat="color in colors" ng-class="{selected: (color===selected)}" ng-click="pick(color)" style="background-color:{{color}};"></li></ul>',
link: function (scope, element, attr) {
scope.colors = scope.customizedColors || defaultColors;
scope.selected = scope.selected || scope.colors[0];
scope.pick = function (color) {
scope.selected = color;
};
}
};
});