-
Notifications
You must be signed in to change notification settings - Fork 2
/
appCtrl.js
42 lines (38 loc) · 1.27 KB
/
appCtrl.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
angular.module( 'demoApp' )
.directive('bindEvents', function() {
return {
restrict: 'A',
link: function(scope, element, attrs) {
eventNames = attrs.bindEvents.split(',');
eventNames.forEach(function(eventName) {
element.bind(eventName, scope[eventName]);
});
}
}
})
.controller( 'appCtrl', function( $scope, $interval) {
$scope.used = 10;
$interval(function() {
if($scope.used > 100) {
$scope.used = 10;
} else {
$scope.used += 10;
}
}, 1000);
$scope.thresholdChangedTextClass = 'ok-text';
$scope.thresholdChangedMsg = "Whew...Everythings normal :-)";
$scope.thresholdSet = function(e) {
var threshold = e.detail.threshold;
var msg = threshold.substr(threshold.lastIndexOf('-') + 1);
if (msg === 'warning') {
$scope.thresholdChangedMsg = "Warning! You should look at this.";
$scope.thresholdChangedTextClass = 'warning-text';
} else if (msg === 'danger') {
$scope.thresholdChangedMsg = "Danger!! Seriously, something's wrong!";
$scope.thresholdChangedTextClass = 'danger-text';
} else if (msg === 'success') {
$scope.thresholdChangedMsg = "Whew...Everythings normal :-)";
$scope.thresholdChangedTextClass = 'ok-text';
}
};
});