-
Notifications
You must be signed in to change notification settings - Fork 108
/
angular.radialIndicator.js
49 lines (39 loc) · 1.79 KB
/
angular.radialIndicator.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
radialIndicator.js v 1.4.0
Author: Sudhanshu Yadav
Copyright (c) 2015,2016 Sudhanshu Yadav - ignitersworld.com , released under the MIT license.
Demo on: ignitersworld.com/lab/radialIndicator.html
*/
/* Angular hook for radialIndicator */
;
(function (angular) {
angular.module('radialIndicator', []).directive('radialIndicator', ['radialIndicatorInstance',
function (radialIndicatorInstance) {
return {
restrict: 'A',
link: function (scope, element, attrs) {
var element = element,
id = attrs.radialIndicatorId,
options = scope.$eval(attrs.radialIndicator),
model = attrs.radialIndicatorModel;
var indInstance = radialIndicator(element, options);
//store indicator instance on radialIndicatorConfig so can get through dependency injection
if (id) radialIndicatorInstance[id] = indInstance;
//watch for modal change
scope.$watch(model, function (newValue) {
indInstance.value(newValue);
});
//delete the idnicator instance when scope dies
scope.$on('$destroy', function () {
if (id) delete radialIndicatorInstance[id];
});
}
}
}])
//a factory to store radial indicators instances which can be injected to controllers or directive to get any indicators instance
.factory('radialIndicatorInstance', function () {
if (!window.radialIndicator) throw "Please include radialIndicator.js";
var radialIndicatorInstance = {};
return radialIndicatorInstance;
});
}(angular));