@angular-wave/angular.ts 0.4.4 → 0.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/dist/angular-ts.esm.js +2 -2
  2. package/dist/angular-ts.umd.js +2 -12
  3. package/index.html +3 -74
  4. package/package.json +1 -1
  5. package/src/angular.spec.js +5 -0
  6. package/src/animations/animate-css.js +13 -5
  7. package/src/animations/animate-queue.js +21 -22
  8. package/src/animations/animate-runner.js +8 -4
  9. package/src/animations/animate.md +1 -1
  10. package/src/animations/animate.spec.js +21 -0
  11. package/src/animations/animation.js +1 -1
  12. package/src/binding.spec.js +1 -0
  13. package/src/core/compile/compile.js +26 -25
  14. package/src/core/compile/compile.spec.js +266 -17
  15. package/src/core/controller/controller.js +0 -2
  16. package/src/core/di/injector.md +1 -1
  17. package/src/core/di/injector.spec.js +2 -0
  18. package/src/core/di/internal-injector.js +1 -2
  19. package/src/core/interpolate/interpolate.js +3 -16
  20. package/src/core/interpolate/interpolate.spec.js +16 -70
  21. package/src/core/interval/interval-factory.js +50 -0
  22. package/src/core/interval/interval.html +18 -0
  23. package/src/core/interval/interval.js +77 -0
  24. package/src/core/interval/interval.md +123 -0
  25. package/src/core/interval/interval.spec.js +280 -0
  26. package/src/core/interval/interval.test.js +1 -1
  27. package/src/core/location/location.js +47 -39
  28. package/src/core/location/location.spec.js +27 -27
  29. package/src/core/on.spec.js +7 -0
  30. package/src/core/parse/interpreter.js +7 -10
  31. package/src/core/parse/parse.js +5 -26
  32. package/src/core/parse/parse.spec.js +91 -95
  33. package/src/core/prop.spec.js +60 -4
  34. package/src/core/q/q.html +18 -0
  35. package/src/core/q/q.js +472 -0
  36. package/src/core/q/q.md +211 -0
  37. package/src/core/q/q.spec.js +2748 -0
  38. package/src/core/q/q.test.js +12 -0
  39. package/src/core/sce/sce.spec.js +8 -0
  40. package/src/core/{model/model.html → scope/scope.html} +1 -1
  41. package/src/core/scope/scope.js +16 -15
  42. package/src/core/scope/scope.spec.js +1959 -24
  43. package/src/core/scope/scope.test.js +12 -0
  44. package/src/core/timeout/timeout.html +18 -0
  45. package/src/core/timeout/timeout.js +109 -0
  46. package/src/core/timeout/timeout.spec.js +354 -0
  47. package/src/core/timeout/timout.test.js +12 -0
  48. package/src/core/url-utils/url-utils.spec.js +1 -1
  49. package/src/directive/aria/aria.js +6 -3
  50. package/src/directive/aria/aria.spec.js +87 -0
  51. package/src/directive/attrs/attrs.spec.js +5 -0
  52. package/src/directive/attrs/boolean.spec.js +15 -0
  53. package/src/directive/attrs/element-style.spec.js +8 -0
  54. package/src/directive/attrs/src.spec.js +7 -0
  55. package/src/directive/bind/bind.spec.js +33 -0
  56. package/src/directive/bind/bing-html.spec.js +3 -0
  57. package/src/directive/class/class.js +3 -3
  58. package/src/directive/class/class.spec.js +75 -9
  59. package/src/directive/controller/controller.spec.js +13 -0
  60. package/src/directive/events/click.spec.js +3 -0
  61. package/src/directive/events/event.spec.js +6 -0
  62. package/src/directive/form/form.js +3 -2
  63. package/src/directive/form/form.spec.js +65 -0
  64. package/src/directive/if/if.spec.js +4 -0
  65. package/src/directive/include/include.spec.js +59 -8
  66. package/src/directive/init/init.js +2 -6
  67. package/src/directive/init/init.spec.js +2 -0
  68. package/src/directive/input/input.spec.js +136 -0
  69. package/src/directive/messages/messages.spec.js +35 -4
  70. package/src/directive/model/model.js +25 -18
  71. package/src/directive/model/model.spec.js +49 -2
  72. package/src/directive/model-options/model-options.spec.js +6 -0
  73. package/src/directive/non-bindable/non-bindable.spec.js +1 -0
  74. package/src/directive/observe/observe.js +1 -0
  75. package/src/directive/observe/observe.spec.js +1 -0
  76. package/src/directive/options/options.spec.js +34 -0
  77. package/src/directive/ref/href.spec.js +15 -0
  78. package/src/directive/repeat/repeat.spec.js +135 -8
  79. package/src/directive/script/script.spec.js +2 -0
  80. package/src/directive/select/select.js +3 -3
  81. package/src/directive/select/select.spec.js +96 -0
  82. package/src/directive/show-hide/show-hide.js +2 -2
  83. package/src/directive/show-hide/show-hide.spec.js +19 -8
  84. package/src/directive/style/style.spec.js +7 -0
  85. package/src/directive/switch/switch.spec.js +5 -5
  86. package/src/directive/validators/validators.spec.js +1 -0
  87. package/src/loader.js +1 -0
  88. package/src/public.js +10 -2
  89. package/src/router/common/coreservices.js +2 -0
  90. package/src/router/directives/state-directives.js +14 -6
  91. package/src/router/directives/state-directives.spec.js +83 -0
  92. package/src/router/directives/view-directive.js +13 -4
  93. package/src/router/directives/view-directive.spec.js +71 -25
  94. package/src/router/hooks/lazy-load.js +2 -2
  95. package/src/router/hooks/views.js +5 -3
  96. package/src/router/resolve/resolvable.js +6 -3
  97. package/src/router/resolve/resolve-context.js +2 -2
  98. package/src/router/state/state-service.js +4 -4
  99. package/src/router/state/state.spec.js +5 -2
  100. package/src/router/state/state.test.js +1 -1
  101. package/src/router/state/views.js +10 -7
  102. package/src/router/template-factory.js +6 -3
  103. package/src/router/template-factory.spec.js +4 -0
  104. package/src/router/transition/transition-hook.js +1 -1
  105. package/src/router/transition/transition.js +1 -1
  106. package/src/router/view-hook.spec.js +2 -2
  107. package/src/router/view-scroll.js +6 -4
  108. package/src/services/browser.js +5 -8
  109. package/src/services/http/http.js +9 -6
  110. package/src/services/http/http.spec.js +31 -30
  111. package/src/services/http/template-request.spec.js +10 -0
  112. package/src/services/http-backend/http-backend.spec.js +3 -3
  113. package/src/services/template-request.js +4 -2
  114. package/src/shared/common.js +2 -1
  115. package/types/core/location/location.d.ts +36 -31
  116. package/types/core/parse/parse.d.ts +0 -26
  117. package/types/core/scope/scope.d.ts +11 -11
  118. package/src/core/model/model.js +0 -944
  119. package/src/core/model/model.spec.js +0 -3012
  120. package/types/core/model/model.d.ts +0 -204
@@ -112,7 +112,6 @@ export class ControllerProvider {
112
112
  instance = Object.create(controllerPrototype || null);
113
113
 
114
114
  if (identifier) {
115
- instance["$controllerIdentifier"] = identifier;
116
115
  this.addIdentifier(
117
116
  locals,
118
117
  identifier,
@@ -135,7 +134,6 @@ export class ControllerProvider {
135
134
  ) {
136
135
  instance = result;
137
136
  if (identifier) {
138
- instance["$controllerIdentifier"] = identifier;
139
137
  this.addIdentifier(
140
138
  locals,
141
139
  identifier,
@@ -28,7 +28,7 @@
28
28
  - // use the type inference to auto inject arguments, or use implicit injection
29
29
  - $injector.invoke(function($rootScope, $compile, $document) {
30
30
  - $compile($document)($rootScope);
31
- - ;
31
+ - $rootScope.$digest();
32
32
  - });
33
33
  - ```
34
34
 
@@ -1410,6 +1410,7 @@ describe("directive", () => {
1410
1410
  injector.loadNewModules(["a"]);
1411
1411
  injector.invoke(($compile, $rootScope) => {
1412
1412
  const elem = $compile("<div a-directive></div>")($rootScope); // compile and link
1413
+ $rootScope.$digest();
1413
1414
  expect(elem.text()).toEqual("test directive");
1414
1415
  elem.remove();
1415
1416
  });
@@ -1423,6 +1424,7 @@ describe("directive", () => {
1423
1424
  injector.loadNewModules(["a"]);
1424
1425
  injector.invoke(($compile, $rootScope) => {
1425
1426
  const elem = $compile("<div a-directive></div>")($rootScope); // compile and link
1427
+ $rootScope.$digest();
1426
1428
  expect(elem.text()).toEqual("test directive");
1427
1429
  elem.remove();
1428
1430
  });
@@ -114,8 +114,7 @@ class AbstractInjector {
114
114
 
115
115
  if (isClass(/** @type {string} */ (fn))) {
116
116
  args.unshift(null);
117
- const res = new (Function.prototype.bind.apply(fn, args))();
118
- return res;
117
+ return new (Function.prototype.bind.apply(fn, args))();
119
118
  } else {
120
119
  return /** @type {Function} */ (fn).apply(self, args);
121
120
  }
@@ -332,25 +332,13 @@ export class InterpolateProvider {
332
332
  };
333
333
 
334
334
  return extend(
335
- (context, cb) => {
335
+ (context) => {
336
336
  let i = 0;
337
337
  const ii = expressions.length;
338
338
  const values = new Array(ii);
339
+
339
340
  try {
340
341
  for (; i < ii; i++) {
341
- if (cb) {
342
- const watchProp = expressions[i].trim();
343
- console.log(watchProp);
344
- context.$watch(watchProp, () => {
345
- let vals = new Array(ii);
346
- let j = 0;
347
- for (; j < ii; j++) {
348
- vals[j] = parseFns[j](context);
349
- }
350
- cb(compute(vals));
351
- });
352
- }
353
-
354
342
  values[i] = parseFns[i](context);
355
343
  }
356
344
 
@@ -360,13 +348,12 @@ export class InterpolateProvider {
360
348
  }
361
349
  },
362
350
  {
363
- // Most likely we would need to register watches during interpolation
364
351
  // all of these properties are undocumented for now
365
352
  exp: text, // just for compatibility with regular watchers created via $watch
366
353
  expressions,
367
354
  $$watchDelegate(scope, listener) {
368
355
  let lastValue;
369
- return scope.$watch(
356
+ return scope.$watchGroup(
370
357
  parseFns,
371
358
  function interpolateFnWatcher(values, oldValues) {
372
359
  const currValue = compute(values);
@@ -1,6 +1,5 @@
1
1
  import { createInjector } from "../di/injector";
2
2
  import { Angular } from "../../loader";
3
- import { wait } from "../../shared/test-utils";
4
3
 
5
4
  describe("$interpolate", () => {
6
5
  let $interpolate, $injector, $rootScope, $sce;
@@ -235,22 +234,18 @@ describe("$interpolate", () => {
235
234
  expect(calls.pop()).toBeUndefined();
236
235
  });
237
236
 
238
- // TODO these tests shoudl be revereds
239
- // Calling interpolation with scope should CREATE watches on scope
240
- it("should stop watching strings with no expressions after first execution", async () => {
237
+ it("should stop watching strings with no expressions after first execution", () => {
241
238
  const spy = jasmine.createSpy();
242
- $rootScope.$watch($interpolate("foo")(), spy);
243
- $rootScope.foo = "foo";
244
- await wait();
245
- expect(spy).toHaveBeenCalledWith("foo", undefined, $rootScope);
239
+ $rootScope.$watch($interpolate("foo"), spy);
240
+ $rootScope.$digest();
241
+ expect(spy).toHaveBeenCalledWith("foo", "foo", $rootScope);
246
242
  expect(spy).toHaveBeenCalledTimes(1);
247
243
  });
248
244
 
249
245
  it("should stop watching strings with only constant expressions after first execution", () => {
250
246
  const spy = jasmine.createSpy();
251
- let res = $interpolate("foo {{42}}")($rootScope);
252
- $rootScope.$watch(res, spy);
253
-
247
+ $rootScope.$watch($interpolate("foo {{42}}"), spy);
248
+ $rootScope.$digest();
254
249
  expect(spy).toHaveBeenCalledWith("foo 42", "foo 42", $rootScope);
255
250
  expect(spy).toHaveBeenCalledTimes(1);
256
251
  });
@@ -269,12 +264,18 @@ describe("$interpolate", () => {
269
264
  expect(interp.$$watchDelegate).toBeDefined();
270
265
  });
271
266
 
272
- it("correctly returns new value", async () => {
267
+ it("correctly returns new and old value when watched", function () {
273
268
  const interp = $interpolate("{{expr}}");
274
- $rootScope.$watch("expr", () => {});
269
+ const listenerSpy = jasmine.createSpy();
270
+ $rootScope.$watch(interp, listenerSpy);
275
271
  $rootScope.expr = 42;
276
- await wait();
277
- expect(interp($rootScope)).toEqual("42");
272
+ $rootScope.$apply();
273
+ expect(listenerSpy.calls.mostRecent().args[0]).toEqual("42");
274
+ expect(listenerSpy.calls.mostRecent().args[1]).toEqual("42");
275
+ $rootScope.expr++;
276
+ $rootScope.$apply();
277
+ expect(listenerSpy.calls.mostRecent().args[0]).toEqual("43");
278
+ expect(listenerSpy.calls.mostRecent().args[1]).toEqual("42");
278
279
  });
279
280
 
280
281
  it("should support escaping interpolation signs", () => {
@@ -398,61 +399,6 @@ describe("$interpolate", () => {
398
399
  });
399
400
  });
400
401
 
401
- describe("interpolation callbacks", () => {
402
- it("does not require a callback", async () => {
403
- let text;
404
- $rootScope.expr = 42;
405
- const interp = $interpolate("{{expr}}");
406
-
407
- text = interp($rootScope);
408
-
409
- expect(text).toEqual("42");
410
- });
411
-
412
- it("correctly invokes callback when interpolated value changes", async () => {
413
- let counter = 0;
414
-
415
- const interp = $interpolate("{{expr}}");
416
-
417
- interp($rootScope, (val) => {
418
- counter++;
419
- });
420
-
421
- $rootScope.expr = 42;
422
- await wait();
423
- expect(counter).toEqual(1);
424
-
425
- $rootScope.expr++;
426
- await wait();
427
- expect(counter).toEqual(2);
428
- });
429
-
430
- it("returns currently interpolated text", async () => {
431
- let text;
432
- $rootScope.expr = 42;
433
- const interp = $interpolate("{{expr}}");
434
-
435
- text = interp($rootScope, (val) => {
436
- text = val;
437
- });
438
-
439
- expect(text).toEqual("42");
440
- });
441
-
442
- it("invokes callback with newly interpolated text", async () => {
443
- let text;
444
- const interp = $interpolate("{{expr}}");
445
-
446
- interp($rootScope, (val) => {
447
- text = val;
448
- });
449
-
450
- $rootScope.expr = 42;
451
- await wait();
452
- expect(text).toEqual("42");
453
- });
454
- });
455
-
456
402
  describe("interpolating in a trusted context", () => {
457
403
  let sce;
458
404
 
@@ -0,0 +1,50 @@
1
+ import { isDefined, sliceArgs } from "../../shared/utils";
2
+
3
+ export function $IntervalFactoryProvider() {
4
+ this.$get = [
5
+ "$q",
6
+ "$rootScope",
7
+ /**
8
+ * @param {*} $q
9
+ * @param {import('../scope/scope').Scope} $rootScope
10
+ * @returns
11
+ */
12
+ function ($q, $rootScope) {
13
+ return function intervalFactory(setIntervalFn, clearIntervalFn) {
14
+ return function intervalFn(fn, delay, count) {
15
+ const hasParams = arguments.length > 4;
16
+ const args = hasParams ? sliceArgs(arguments, 4) : [];
17
+ let iteration = 0;
18
+ const deferred = $q.defer();
19
+ const { promise } = deferred;
20
+
21
+ count = isDefined(count) ? count : 0;
22
+
23
+ function callback() {
24
+ if (!hasParams) {
25
+ fn(iteration);
26
+ } else {
27
+ fn.apply(null, args);
28
+ }
29
+ }
30
+
31
+ function tick() {
32
+ $rootScope.$evalAsync(callback);
33
+
34
+ iteration++;
35
+
36
+ if (count > 0 && iteration >= count) {
37
+ deferred.resolve(iteration);
38
+ clearIntervalFn(promise.$$intervalId);
39
+ }
40
+ $rootScope.$apply();
41
+ }
42
+
43
+ promise.$$intervalId = setIntervalFn(tick, delay, deferred);
44
+
45
+ return promise;
46
+ };
47
+ };
48
+ },
49
+ ];
50
+ }
@@ -0,0 +1,18 @@
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <title>AngularTS Test Runner</title>
6
+
7
+ <link rel="shortcut icon" type="image/png" href="/images/favicon.ico" />
8
+ <link rel="stylesheet" href="/jasmine/jasmine-5.1.2/jasmine.css" />
9
+ <script src="/jasmine/jasmine-5.1.2/jasmine.js"></script>
10
+ <script src="/jasmine/jasmine-5.1.2/jasmine-html.js"></script>
11
+ <script src="/jasmine/jasmine-5.1.2/boot0.js"></script>
12
+ <script src="/jasmine/jasmine-5.1.2/boot1.js"></script>
13
+ <script type="module" src="/src/core/interval/interval.spec.js"></script>
14
+ </head>
15
+ <body>
16
+ <div id="dummy"></div>
17
+ </body>
18
+ </html>
@@ -0,0 +1,77 @@
1
+ import { markQExceptionHandled } from "../q/q";
2
+ import { minErr } from "../../shared/utils";
3
+
4
+ const $intervalMinErr = minErr("$interval");
5
+
6
+ /**
7
+ * @typedef {number} IntervalId
8
+ * Interval ID which uniquely identifies the interval and can be used to cancel it
9
+ */
10
+
11
+ /**
12
+ * @type {Map<IntervalId, import("../q/q").Deferred<any>>}
13
+ */
14
+ const intervals = new Map();
15
+
16
+ export function IntervalProvider() {
17
+ this.$get = [
18
+ "$$intervalFactory",
19
+ // TODO Add type
20
+ function ($$intervalFactory) {
21
+ /**
22
+ * @param {TimerHandler} tick
23
+ * @param {number} delay
24
+ * @param {import("../q/q").Deferred<any>} deferred
25
+ * @returns {IntervalId} - This method returns an interval ID which uniquely identifies the interval
26
+ */
27
+ function setIntervalFn(tick, delay, deferred) {
28
+ const id = window.setInterval(tick, delay);
29
+ intervals.set(id, deferred);
30
+ return id;
31
+ }
32
+
33
+ /**s
34
+ * @param {IntervalId} id
35
+ */
36
+ function clearIntervalFn(id) {
37
+ window.clearInterval(id);
38
+ intervals.delete(id);
39
+ }
40
+
41
+ const interval = $$intervalFactory(setIntervalFn, clearIntervalFn);
42
+
43
+ /**
44
+ * Cancels a task associated with the `promise`.
45
+ *
46
+ * @param {!import("../q/q").QPromise<any>} promise returned by the `$interval` function.
47
+ * @returns {boolean} Returns `true` if the task was successfully canceled.
48
+ */
49
+ interval.cancel = function (promise) {
50
+ if (!promise) return false;
51
+
52
+ if (!Object.prototype.hasOwnProperty.call(promise, "$$intervalId")) {
53
+ throw $intervalMinErr(
54
+ "badprom",
55
+ "`$interval.cancel()` called with a promise that was not generated by `$interval()`.",
56
+ );
57
+ }
58
+
59
+ if (!intervals.has(promise.$$intervalId)) {
60
+ return false;
61
+ }
62
+
63
+ const id = promise.$$intervalId;
64
+ const deferred = intervals.get(id);
65
+
66
+ // Interval cancels should not report an unhandled promise.
67
+ markQExceptionHandled(deferred.promise);
68
+ deferred.reject("canceled");
69
+ clearIntervalFn(id);
70
+
71
+ return true;
72
+ };
73
+
74
+ return interval;
75
+ },
76
+ ];
77
+ }
@@ -0,0 +1,123 @@
1
+ /**
2
+ _ @ngdoc service
3
+ _ @name $interval
4
+ *
5
+ * @description
6
+ * AngularJS's wrapper for `window.setInterval`. The `fn` function is executed every `delay`
7
+ * milliseconds.
8
+ *
9
+ * The return value of registering an interval function is a promise. This promise will be
10
+ * notified upon each tick of the interval, and will be resolved after `count` iterations, or
11
+ * run indefinitely if `count` is not defined. The value of the notification will be the
12
+ * number of iterations that have run.
13
+ * To cancel an interval, call `$interval.cancel(promise)`.
14
+ *
15
+ * In tests you can use {@link ngMock.$interval#flush `$interval.flush(millis)`} to
16
+ * move forward by `millis` milliseconds and trigger any functions scheduled to run in that
17
+ _ time.
18
+ _
19
+ _ <div class="alert alert-warning">
20
+ _ **Note\*_: Intervals created by this service must be explicitly destroyed when you are finished
21
+ _ with them. In particular they are not automatically destroyed when a controller's scope or a
22
+ _ directive's element are destroyed.
23
+ _ You should take this into consideration and make sure to always cancel the interval at the
24
+ _ appropriate moment. See the example below for more details on how and when to do this.
25
+ _ </div> \*
26
+ _ @param {function()} fn A function that should be called repeatedly. If no additional arguments
27
+ _ are passed (see below), the function is called with the current iteration count.
28
+ _ @param {number} delay Number of milliseconds between each function call.
29
+ _ @param {number=} [count=0] Number of times to repeat. If not set, or 0, will repeat
30
+ _ indefinitely.
31
+ _ @param {boolean=} [invokeApply=true] If set to `false` skips model dirty checking, otherwise
32
+ _ will invoke `fn` within the {@link ng.$rootScope.Scope#$apply $apply} block.
33
+ _ @param {..._=} Pass additional parameters to the executed function.
34
+ _ @returns {promise} A promise which will be notified on each iteration. It will resolve once all iterations of the interval complete. \*
35
+ _ @example
36
+ _ <example module="intervalExample" name="interval-service">
37
+ _ <file name="index.html">
38
+ _ <script>
39
+ _ angular.module('intervalExample', [])
40
+ _ .controller('ExampleController', ['$scope', '$interval',
41
+
42
+ - function($scope, $interval) {
43
+ - $scope.format = 'M/d/yy h:mm:ss a';
44
+ - $scope.blood_1 = 100;
45
+ - $scope.blood_2 = 120;
46
+ -
47
+ - let stop;
48
+ - $scope.fight = function() {
49
+ - // Don't start a new fight if we are already fighting
50
+ - if ( angular.isDefined(stop) ) return;
51
+ -
52
+ - stop = $interval(function() {
53
+ - if ($scope.blood_1 > 0 && $scope.blood_2 > 0) {
54
+ - $scope.blood_1 = $scope.blood_1 - 3;
55
+ - $scope.blood_2 = $scope.blood_2 - 4;
56
+ - } else {
57
+ - $scope.stopFight();
58
+ - }
59
+ - }, 100);
60
+ - };
61
+ -
62
+ - $scope.stopFight = function() {
63
+ - if (angular.isDefined(stop)) {
64
+ - $interval.cancel(stop);
65
+ - stop = undefined;
66
+ - }
67
+ - };
68
+ -
69
+ - $scope.resetFight = function() {
70
+ - $scope.blood_1 = 100;
71
+ - $scope.blood_2 = 120;
72
+ - };
73
+ -
74
+ - $scope.$on('$destroy', function() {
75
+ - // Make sure that the interval is destroyed too
76
+ - $scope.stopFight();
77
+ - });
78
+ - }])
79
+ _ // Register the 'myCurrentTime' directive factory method.
80
+ _ // We inject $interval and dateFilter service since the factory method is DI.
81
+ * .directive('myCurrentTime', ['$interval', 'dateFilter',
82
+ _ function($interval, dateFilter) {
83
+ _ // return the directive link function. (compile function not needed)
84
+ _ return function(scope, element, attrs) {
85
+ _ let format, // date format
86
+ _ stopTime; // so that we can cancel the time updates
87
+ _
88
+ _ // used to update the UI
89
+ _ function updateTime() {
90
+ _ element.text(dateFilter(new Date(), format));
91
+ _ } \*
92
+ _ // watch the expression, and update the UI on change.
93
+ _ scope.$watch(attrs.myCurrentTime, function(value) {
94
+ * format = value;
95
+ * updateTime();
96
+ * });
97
+ *
98
+ * stopTime = $interval(updateTime, 1000);
99
+ *
100
+ * // listen on DOM destroy (removal) event, and cancel the next UI update
101
+ * // to prevent updating time after the DOM element was removed.
102
+ * element.on('$destroy', function() {
103
+ _ $interval.cancel(stopTime);
104
+ _ });
105
+ _ }
106
+ _ }]);
107
+ _ </script>
108
+ _
109
+ _ <div>
110
+ _ <div ng-controller="ExampleController">
111
+ _ <label>Date format: <input ng-model="format"></label> <hr/>
112
+ _ Current time is: <span my-current-time="format"></span>
113
+ _ <hr/>
114
+ _ Blood 1 : <font color='red'>{{blood_1}}</font>
115
+ _ Blood 2 : <font color='red'>{{blood_2}}</font>
116
+ _ <button type="button" data-ng-click="fight()">Fight</button>
117
+ _ <button type="button" data-ng-click="stopFight()">StopFight</button>
118
+ _ <button type="button" data-ng-click="resetFight()">resetFight</button>
119
+ _ </div>
120
+ _ </div> \*
121
+ _ </file>
122
+ _ </example>
123
+ \*/