@@ -42,25 +42,27 @@ function $IntervalProvider() {
42
42
* @returns {promise } A promise which will be notified on each iteration.
43
43
*
44
44
* @example
45
- * <example module="time">
46
- * <file name="index.html">
47
- * <script>
48
- * function Ctrl2($scope,$interval) {
49
- * $scope.format = 'M/d/yy h:mm:ss a';
50
- * $scope.blood_1 = 100;
51
- * $scope.blood_2 = 120;
52
- *
53
- * var stop;
54
- * $scope.fight = function() {
55
- * // Don't start a new fight if we are already fighting
56
- * if ( angular.isDefined(stop) ) return;
45
+ * <example module="intervalExample">
46
+ * <file name="index.html">
47
+ * <script>
48
+ * angular.module('intervalExample', [])
49
+ * .controller('ExampleController', ['$scope', '$interval',
50
+ * function($scope, $interval) {
51
+ * $scope.format = 'M/d/yy h:mm:ss a';
52
+ * $scope.blood_1 = 100;
53
+ * $scope.blood_2 = 120;
54
+ *
55
+ * var stop;
56
+ * $scope.fight = function() {
57
+ * // Don't start a new fight if we are already fighting
58
+ * if ( angular.isDefined(stop) ) return;
57
59
*
58
60
* stop = $interval(function() {
59
61
* if ($scope.blood_1 > 0 && $scope.blood_2 > 0) {
60
- * $scope.blood_1 = $scope.blood_1 - 3;
61
- * $scope.blood_2 = $scope.blood_2 - 4;
62
+ * $scope.blood_1 = $scope.blood_1 - 3;
63
+ * $scope.blood_2 = $scope.blood_2 - 4;
62
64
* } else {
63
- * $scope.stopFight();
65
+ * $scope.stopFight();
64
66
* }
65
67
* }, 100);
66
68
* };
@@ -75,22 +77,21 @@ function $IntervalProvider() {
75
77
* $scope.resetFight = function() {
76
78
* $scope.blood_1 = 100;
77
79
* $scope.blood_2 = 120;
78
- * }
80
+ * };
79
81
*
80
82
* $scope.$on('$destroy', function() {
81
- * // Make sure that the interval is destroyed too
83
+ * // Make sure that the interval nis destroyed too
82
84
* $scope.stopFight();
83
85
* });
84
- * }
85
- *
86
- * angular.module('time', [])
87
- * // Register the 'myCurrentTime' directive factory method.
88
- * // We inject $interval and dateFilter service since the factory method is DI.
89
- * .directive('myCurrentTime', function($interval, dateFilter) {
86
+ * })
87
+ * // Register the 'myCurrentTime' directive factory method.
88
+ * // We inject $interval and dateFilter service since the factory method is DI.
89
+ * .directive('myCurrentTime', ['$interval', 'dateFilter',
90
+ * function($interval, dateFilter) {
90
91
* // return the directive link function. (compile function not needed)
91
92
* return function(scope, element, attrs) {
92
93
* var format, // date format
93
- * stopTime; // so that we can cancel the time updates
94
+ * stopTime; // so that we can cancel the time updates
94
95
*
95
96
* // used to update the UI
96
97
* function updateTime() {
@@ -106,28 +107,28 @@ function $IntervalProvider() {
106
107
* stopTime = $interval(updateTime, 1000);
107
108
*
108
109
* // listen on DOM destroy (removal) event, and cancel the next UI update
109
- * // to prevent updating time ofter the DOM element was removed.
110
+ * // to prevent updating time after the DOM element was removed.
110
111
* element.on('$destroy', function() {
111
112
* $interval.cancel(stopTime);
112
113
* });
113
114
* }
114
115
* });
115
- * </script>
116
- *
117
- * <div>
118
- * <div ng-controller="Ctrl2">
119
- * Date format: <input ng-model="format"> <hr/>
120
- * Current time is: <span my-current-time="format"></span>
121
- * <hr/>
122
- * Blood 1 : <font color='red'>{{blood_1}}</font>
123
- * Blood 2 : <font color='red'>{{blood_2}}</font>
124
- * <button type="button" data-ng-click="fight()">Fight</button>
125
- * <button type="button" data-ng-click="stopFight()">StopFight</button>
126
- * <button type="button" data-ng-click="resetFight()">resetFight</button>
127
- * </div>
116
+ * </script>
117
+ *
118
+ * <div>
119
+ * <div ng-controller="ExampleController">
120
+ * Date format: <input ng-model="format"> <hr/>
121
+ * Current time is: <span my-current-time="format"></span>
122
+ * <hr/>
123
+ * Blood 1 : <font color='red'>{{blood_1}}</font>
124
+ * Blood 2 : <font color='red'>{{blood_2}}</font>
125
+ * <button type="button" data-ng-click="fight()">Fight</button>
126
+ * <button type="button" data-ng-click="stopFight()">StopFight</button>
127
+ * <button type="button" data-ng-click="resetFight()">resetFight</button>
128
128
* </div>
129
+ * </div>
129
130
*
130
- * </file>
131
+ * </file>
131
132
* </example>
132
133
*/
133
134
function interval ( fn , delay , count , invokeApply ) {
0 commit comments