Repository navigation
Expand file tree
/
Copy pathangularjs-multiple-timers.html
More file actions
43 lines (40 loc) · 1.82 KB
/
Copy pathangularjs-multiple-timers.html
File metadata and controls
43 lines (40 loc) · 1.82 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
42
43
<!DOCTYPE html>
<html>
<head>
<title>AngularJS Example - Multiple Timers Example</title>
<script src="../bower_components/angular/angular.min.js"></script>
<script src="../bower_components/jquery/jquery.min.js"></script>
<script src="../bower_components/bootstrap/docs/assets/js/bootstrap.min.js"></script>
<script src="../bower_components/momentjs/min/moment.min.js"></script>
<script src="../bower_components/momentjs/min/locales.min.js"></script>
<script src="../bower_components/humanize-duration/humanize-duration.js"></script>
<script src="../dist/angular-timer.js"></script>
<script>
angular.module('MyApp', ['timer'])
.controller('MyAppController', ['$scope', function ($scope) {
$scope.timerRunning = true;
$scope.startTimer = function (){
$scope.$broadcast('timer-start');
$scope.timerRunning = true;
};
$scope.stopTimer = function (){
$scope.$broadcast('timer-stop');
$scope.timerRunning = false;
};
$scope.$on('timer-stopped', function (event, args) {
console.log('timer-stopped args = ', args);
});
}]);
</script>
</head>
<body ng-app="MyApp">
<div ng-controller="MyAppController">
<h2>AngularJS - Multiple Timers Example</h2>
<h3>Timer 1: <timer/></h3>
<h3>Timer 2: <timer interval="2000"/></h3>
<h3>Timer 3: <timer>{{minutes}} minutes, {{seconds}} seconds.</timer></h3>
<button ng-click="startTimer()" ng-disabled="timerRunning">Start Timers</button>
<button ng-click="stopTimer()" ng-disabled="!timerRunning">Stop Timers</button>
</div>
</body>
</html>