forked from dsjoerg/ggtracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtimeselect.js
More file actions
39 lines (34 loc) · 1.15 KB
/
Copy pathtimeselect.js
File metadata and controls
39 lines (34 loc) · 1.15 KB
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
36
37
38
39
gg.directive('timeselect', [function() {
return {
restrict: 'E',
transclude: true,
replace: true,
scope: {
selected: '=name'
},
link: function(scope, element, attrs) {
scope.$watch('times', function(times) {
// console.log("in times watch", times);
if (times.length > 0) {
scope.select = $(element).select2({
placeholder: 'at time ',
allowClear: true,
containerCssClass: 's2times'
});
scope.$watch('selected', function(v) {
if(v) {
// console.log("Hi DJJJ!", v, scope.selected, $(element), $(element).children('.s2times'));
$(element).parent().children('.s2times').select2('val', scope.selected);
}
});
}
});
scope.times = [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 25, 30, 35, 40];
},
template:
'<select ng-model="selected">' +
'<option></option>' +
'<option ng-repeat="time in times" value="{{ time }}" ng-selected="(selected == time)">@ {{ time }}:00</option>' +
'</select>'
}
}]);