-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathangular-gauge.js
More file actions
41 lines (37 loc) · 1.39 KB
/
Copy pathangular-gauge.js
File metadata and controls
41 lines (37 loc) · 1.39 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
40
41
angular.module('gaugejs', [])
.directive('gaugejs', function () {
return {
restrict: 'A',
scope: {
options: '=',
value: '=ngModel'
},
compile: function (ele, attrs) {
var gauge;
return function (scope, element, attrs) {
function setGauge(options, value) {
value = (value ? value : 0);
if (!gauge) {
gauge = new Gauge(element[0]).setOptions(options);
}
gauge.setOptions(options);
gauge.maxValue = options.maxValue;
gauge.setMinValue = options.minValue;
gauge.set(value);
gauge.animationSpeed = options.animationSpeed;
}
scope.$watch('options', function (newVal, oldVal) {
setGauge(newVal);
}, true);
scope.$watch('value', function (newVal, oldVal) {
value = (newVal ? newVal : 0);
if (value > scope.options.maxValue) {
setGauge(scope.options, scope.options.maxValue);
} else {
setGauge(scope.options, newVal);
}
}, true);
};
}
};
});