@angular-wave/angular.ts 0.0.6 → 0.0.7
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.
- package/package.json +1 -1
- package/src/core/compile.js +2 -3
- package/src/core/filter.js +0 -110
- package/src/core/filter.md +126 -0
- package/src/core/interval.js +0 -126
- package/src/core/interval.md +122 -0
- package/src/core/location.js +1 -2
- package/src/injector.js +0 -630
- package/src/injector.md +711 -0
- package/src/jqLite.js +1 -1
- package/src/loader.js +1 -15
- package/src/loader.md +13 -0
- package/test/jqlite.spec.js +4 -4
- package/test/ng/compile.spec.js +27 -27
- package/src/route-to-reg-exp.js +0 -41
package/package.json
CHANGED
package/src/core/compile.js
CHANGED
|
@@ -940,7 +940,6 @@ export function $CompileProvider($provide, $$sanitizeUriProvider) {
|
|
|
940
940
|
const booleanKey = getBooleanAttrName(node, key);
|
|
941
941
|
const aliasedKey = ALIASED_ATTR[key];
|
|
942
942
|
let observer = key;
|
|
943
|
-
let nodeName;
|
|
944
943
|
|
|
945
944
|
if (booleanKey) {
|
|
946
945
|
this.$$element[0][key] = value;
|
|
@@ -962,7 +961,7 @@ export function $CompileProvider($provide, $$sanitizeUriProvider) {
|
|
|
962
961
|
}
|
|
963
962
|
}
|
|
964
963
|
|
|
965
|
-
nodeName =
|
|
964
|
+
let nodeName = this.$$element[0].nodeName.toLowerCase();
|
|
966
965
|
|
|
967
966
|
// Sanitize img[srcset] values.
|
|
968
967
|
if (nodeName === "img" && key === "srcset") {
|
|
@@ -1461,7 +1460,7 @@ export function $CompileProvider($provide, $$sanitizeUriProvider) {
|
|
|
1461
1460
|
|
|
1462
1461
|
switch (nodeType) {
|
|
1463
1462
|
case Node.ELEMENT_NODE /* Element */:
|
|
1464
|
-
nodeName =
|
|
1463
|
+
nodeName = node.nodeName.toLowerCase();
|
|
1465
1464
|
|
|
1466
1465
|
// use the node name: <directive>
|
|
1467
1466
|
addDirective(
|
package/src/core/filter.js
CHANGED
|
@@ -4,120 +4,10 @@ import { jsonFilter } from "../filters/filters";
|
|
|
4
4
|
import { limitToFilter } from "../filters/limit-to";
|
|
5
5
|
import { orderByFilter } from "../filters/order-by";
|
|
6
6
|
|
|
7
|
-
/**
|
|
8
|
-
* @ngdoc provider
|
|
9
|
-
* @name $filterProvider
|
|
10
|
-
* @description
|
|
11
|
-
*
|
|
12
|
-
* Filters are just functions which transform input to an output. However filters need to be
|
|
13
|
-
* Dependency Injected. To achieve this a filter definition consists of a factory function which is
|
|
14
|
-
* annotated with dependencies and is responsible for creating a filter function.
|
|
15
|
-
*
|
|
16
|
-
* <div class="alert alert-warning">
|
|
17
|
-
* **Note:** Filter names must be valid AngularJS {@link expression} identifiers, such as `uppercase` or `orderBy`.
|
|
18
|
-
* Names with special characters, such as hyphens and dots, are not allowed. If you wish to namespace
|
|
19
|
-
* your filters, then you can use capitalization (`myappSubsectionFilterx`) or underscores
|
|
20
|
-
* (`myapp_subsection_filterx`).
|
|
21
|
-
* </div>
|
|
22
|
-
*
|
|
23
|
-
* ```js
|
|
24
|
-
* // Filter registration
|
|
25
|
-
* function MyModule($provide, $filterProvider) {
|
|
26
|
-
* // create a service to demonstrate injection (not always needed)
|
|
27
|
-
* $provide.value('greet', function(name){
|
|
28
|
-
* return 'Hello ' + name + '!';
|
|
29
|
-
* });
|
|
30
|
-
*
|
|
31
|
-
* // register a filter factory which uses the
|
|
32
|
-
* // greet service to demonstrate DI.
|
|
33
|
-
* $filterProvider.register('greet', function(greet){
|
|
34
|
-
* // return the filter function which uses the greet service
|
|
35
|
-
* // to generate salutation
|
|
36
|
-
* return function(text) {
|
|
37
|
-
* // filters need to be forgiving so check input validity
|
|
38
|
-
* return text && greet(text) || text;
|
|
39
|
-
* };
|
|
40
|
-
* });
|
|
41
|
-
* }
|
|
42
|
-
* ```
|
|
43
|
-
*
|
|
44
|
-
* The filter function is registered with the `$injector` under the filter name suffix with
|
|
45
|
-
* `Filter`.
|
|
46
|
-
*
|
|
47
|
-
* ```js
|
|
48
|
-
* it('should be the same instance', inject(
|
|
49
|
-
* function($filterProvider) {
|
|
50
|
-
* $filterProvider.register('reverse', function(){
|
|
51
|
-
* return ...;
|
|
52
|
-
* });
|
|
53
|
-
* },
|
|
54
|
-
* function($filter, reverseFilter) {
|
|
55
|
-
* expect($filter('reverse')).toBe(reverseFilter);
|
|
56
|
-
* });
|
|
57
|
-
* ```
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
* For more information about how AngularJS filters work, and how to create your own filters, see
|
|
61
|
-
* {@link guide/filter Filters} in the AngularJS Developer Guide.
|
|
62
|
-
*/
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* @ngdoc service
|
|
66
|
-
* @name $filter
|
|
67
|
-
* @kind function
|
|
68
|
-
* @description
|
|
69
|
-
* Filters are used for formatting data displayed to the user.
|
|
70
|
-
*
|
|
71
|
-
* They can be used in view templates, controllers or services. AngularJS comes
|
|
72
|
-
* with a collection of [built-in filters](api/ng/filter), but it is easy to
|
|
73
|
-
* define your own as well.
|
|
74
|
-
*
|
|
75
|
-
* The general syntax in templates is as follows:
|
|
76
|
-
*
|
|
77
|
-
* ```html
|
|
78
|
-
* {{ expression [| filter_name[:parameter_value] ... ] }}
|
|
79
|
-
* ```
|
|
80
|
-
*
|
|
81
|
-
* @param {String} name Name of the filter function to retrieve
|
|
82
|
-
* @return {Function} the filter function
|
|
83
|
-
* @example
|
|
84
|
-
<example name="$filter" module="filterExample">
|
|
85
|
-
<file name="index.html">
|
|
86
|
-
<div ng-controller="MainCtrl">
|
|
87
|
-
<h3>{{ originalText }}</h3>
|
|
88
|
-
<h3>{{ filteredText }}</h3>
|
|
89
|
-
</div>
|
|
90
|
-
</file>
|
|
91
|
-
|
|
92
|
-
<file name="script.js">
|
|
93
|
-
angular.module('filterExample', [])
|
|
94
|
-
.controller('MainCtrl', function($scope, $filter) {
|
|
95
|
-
$scope.originalText = 'hello';
|
|
96
|
-
$scope.filteredText = $filter('uppercase')($scope.originalText);
|
|
97
|
-
});
|
|
98
|
-
</file>
|
|
99
|
-
</example>
|
|
100
|
-
*/
|
|
101
7
|
$FilterProvider.$inject = ["$provide"];
|
|
102
8
|
export function $FilterProvider($provide) {
|
|
103
9
|
const suffix = "Filter";
|
|
104
10
|
|
|
105
|
-
/**
|
|
106
|
-
* @ngdoc method
|
|
107
|
-
* @name $filterProvider#register
|
|
108
|
-
* @param {string|Object} name Name of the filter function, or an object map of filters where
|
|
109
|
-
* the keys are the filter names and the values are the filter factories.
|
|
110
|
-
*
|
|
111
|
-
* <div class="alert alert-warning">
|
|
112
|
-
* **Note:** Filter names must be valid AngularJS {@link expression} identifiers, such as `uppercase` or `orderBy`.
|
|
113
|
-
* Names with special characters, such as hyphens and dots, are not allowed. If you wish to namespace
|
|
114
|
-
* your filters, then you can use capitalization (`myappSubsectionFilterx`) or underscores
|
|
115
|
-
* (`myapp_subsection_filterx`).
|
|
116
|
-
* </div>
|
|
117
|
-
* @param {Function} factory If the first argument was a string, a factory function for the filter to be registered.
|
|
118
|
-
* @returns {Object} Registered filter instance, or if a map of filters was provided then a map
|
|
119
|
-
* of the registered filter instances.
|
|
120
|
-
*/
|
|
121
11
|
function register(name, factory) {
|
|
122
12
|
if (isObject(name)) {
|
|
123
13
|
const filters = {};
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/\*\*
|
|
2
|
+
|
|
3
|
+
- @ngdoc provider
|
|
4
|
+
- @name $filterProvider
|
|
5
|
+
- @description
|
|
6
|
+
-
|
|
7
|
+
- Filters are just functions which transform input to an output. However filters need to be
|
|
8
|
+
- Dependency Injected. To achieve this a filter definition consists of a factory function which is
|
|
9
|
+
- annotated with dependencies and is responsible for creating a filter function.
|
|
10
|
+
-
|
|
11
|
+
- <div class="alert alert-warning">
|
|
12
|
+
- **Note:** Filter names must be valid AngularJS {@link expression} identifiers, such as `uppercase` or `orderBy`.
|
|
13
|
+
- Names with special characters, such as hyphens and dots, are not allowed. If you wish to namespace
|
|
14
|
+
- your filters, then you can use capitalization (`myappSubsectionFilterx`) or underscores
|
|
15
|
+
- (`myapp_subsection_filterx`).
|
|
16
|
+
- </div>
|
|
17
|
+
-
|
|
18
|
+
- ```js
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
- // Filter registration
|
|
22
|
+
- function MyModule($provide, $filterProvider) {
|
|
23
|
+
- // create a service to demonstrate injection (not always needed)
|
|
24
|
+
- $provide.value('greet', function(name){
|
|
25
|
+
- return 'Hello ' + name + '!';
|
|
26
|
+
- });
|
|
27
|
+
-
|
|
28
|
+
- // register a filter factory which uses the
|
|
29
|
+
- // greet service to demonstrate DI.
|
|
30
|
+
- $filterProvider.register('greet', function(greet){
|
|
31
|
+
- // return the filter function which uses the greet service
|
|
32
|
+
- // to generate salutation
|
|
33
|
+
- return function(text) {
|
|
34
|
+
- // filters need to be forgiving so check input validity
|
|
35
|
+
- return text && greet(text) || text;
|
|
36
|
+
- };
|
|
37
|
+
- });
|
|
38
|
+
- }
|
|
39
|
+
- ```
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
-
|
|
43
|
+
- The filter function is registered with the `$injector` under the filter name suffix with
|
|
44
|
+
- `Filter`.
|
|
45
|
+
-
|
|
46
|
+
- ```js
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
- it('should be the same instance', inject(
|
|
50
|
+
- function($filterProvider) {
|
|
51
|
+
- $filterProvider.register('reverse', function(){
|
|
52
|
+
- return ...;
|
|
53
|
+
- });
|
|
54
|
+
- },
|
|
55
|
+
- function($filter, reverseFilter) {
|
|
56
|
+
- expect($filter('reverse')).toBe(reverseFilter);
|
|
57
|
+
- });
|
|
58
|
+
- ```
|
|
59
|
+
|
|
60
|
+
```
|
|
61
|
+
-
|
|
62
|
+
-
|
|
63
|
+
- For more information about how AngularJS filters work, and how to create your own filters, see
|
|
64
|
+
- {@link guide/filter Filters} in the AngularJS Developer Guide.
|
|
65
|
+
\*/
|
|
66
|
+
|
|
67
|
+
/\*\*
|
|
68
|
+
|
|
69
|
+
- @ngdoc service
|
|
70
|
+
- @name $filter
|
|
71
|
+
- @kind function
|
|
72
|
+
- @description
|
|
73
|
+
- Filters are used for formatting data displayed to the user.
|
|
74
|
+
-
|
|
75
|
+
- They can be used in view templates, controllers or services. AngularJS comes
|
|
76
|
+
- with a collection of [built-in filters](api/ng/filter), but it is easy to
|
|
77
|
+
- define your own as well.
|
|
78
|
+
-
|
|
79
|
+
- The general syntax in templates is as follows:
|
|
80
|
+
-
|
|
81
|
+
- ```html
|
|
82
|
+
|
|
83
|
+
```
|
|
84
|
+
- {{ expression [| filter_name[:parameter_value] ... ] }}
|
|
85
|
+
- ```
|
|
86
|
+
|
|
87
|
+
```
|
|
88
|
+
-
|
|
89
|
+
- @param {String} name Name of the filter function to retrieve
|
|
90
|
+
- @return {Function} the filter function
|
|
91
|
+
- @example
|
|
92
|
+
<example name="$filter" module="filterExample">
|
|
93
|
+
<file name="index.html">
|
|
94
|
+
<div ng-controller="MainCtrl">
|
|
95
|
+
<h3>{{ originalText }}</h3>
|
|
96
|
+
<h3>{{ filteredText }}</h3>
|
|
97
|
+
</div>
|
|
98
|
+
</file>
|
|
99
|
+
|
|
100
|
+
<file name="script.js">
|
|
101
|
+
angular.module('filterExample', [])
|
|
102
|
+
.controller('MainCtrl', function($scope, $filter) {
|
|
103
|
+
$scope.originalText = 'hello';
|
|
104
|
+
$scope.filteredText = $filter('uppercase')($scope.originalText);
|
|
105
|
+
});
|
|
106
|
+
</file>
|
|
107
|
+
</example>
|
|
108
|
+
*/
|
|
109
|
+
|
|
110
|
+
/\*\*
|
|
111
|
+
|
|
112
|
+
- @ngdoc method
|
|
113
|
+
- @name $filterProvider#register
|
|
114
|
+
- @param {string|Object} name Name of the filter function, or an object map of filters where
|
|
115
|
+
- the keys are the filter names and the values are the filter factories.
|
|
116
|
+
-
|
|
117
|
+
- <div class="alert alert-warning">
|
|
118
|
+
- **Note:** Filter names must be valid AngularJS {@link expression} identifiers, such as `uppercase` or `orderBy`.
|
|
119
|
+
- Names with special characters, such as hyphens and dots, are not allowed. If you wish to namespace
|
|
120
|
+
- your filters, then you can use capitalization (`myappSubsectionFilterx`) or underscores
|
|
121
|
+
- (`myapp_subsection_filterx`).
|
|
122
|
+
- </div>
|
|
123
|
+
- @param {Function} factory If the first argument was a string, a factory function for the filter to be registered.
|
|
124
|
+
- @returns {Object} Registered filter instance, or if a map of filters was provided then a map
|
|
125
|
+
- of the registered filter instances.
|
|
126
|
+
\*/
|
package/src/core/interval.js
CHANGED
|
@@ -18,132 +18,6 @@ export function $IntervalProvider() {
|
|
|
18
18
|
delete intervals[id];
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
/**
|
|
22
|
-
* @ngdoc service
|
|
23
|
-
* @name $interval
|
|
24
|
-
*
|
|
25
|
-
* @description
|
|
26
|
-
* AngularJS's wrapper for `window.setInterval`. The `fn` function is executed every `delay`
|
|
27
|
-
* milliseconds.
|
|
28
|
-
*
|
|
29
|
-
* The return value of registering an interval function is a promise. This promise will be
|
|
30
|
-
* notified upon each tick of the interval, and will be resolved after `count` iterations, or
|
|
31
|
-
* run indefinitely if `count` is not defined. The value of the notification will be the
|
|
32
|
-
* number of iterations that have run.
|
|
33
|
-
* To cancel an interval, call `$interval.cancel(promise)`.
|
|
34
|
-
*
|
|
35
|
-
* In tests you can use {@link ngMock.$interval#flush `$interval.flush(millis)`} to
|
|
36
|
-
* move forward by `millis` milliseconds and trigger any functions scheduled to run in that
|
|
37
|
-
* time.
|
|
38
|
-
*
|
|
39
|
-
* <div class="alert alert-warning">
|
|
40
|
-
* **Note**: Intervals created by this service must be explicitly destroyed when you are finished
|
|
41
|
-
* with them. In particular they are not automatically destroyed when a controller's scope or a
|
|
42
|
-
* directive's element are destroyed.
|
|
43
|
-
* You should take this into consideration and make sure to always cancel the interval at the
|
|
44
|
-
* appropriate moment. See the example below for more details on how and when to do this.
|
|
45
|
-
* </div>
|
|
46
|
-
*
|
|
47
|
-
* @param {function()} fn A function that should be called repeatedly. If no additional arguments
|
|
48
|
-
* are passed (see below), the function is called with the current iteration count.
|
|
49
|
-
* @param {number} delay Number of milliseconds between each function call.
|
|
50
|
-
* @param {number=} [count=0] Number of times to repeat. If not set, or 0, will repeat
|
|
51
|
-
* indefinitely.
|
|
52
|
-
* @param {boolean=} [invokeApply=true] If set to `false` skips model dirty checking, otherwise
|
|
53
|
-
* will invoke `fn` within the {@link ng.$rootScope.Scope#$apply $apply} block.
|
|
54
|
-
* @param {...*=} Pass additional parameters to the executed function.
|
|
55
|
-
* @returns {promise} A promise which will be notified on each iteration. It will resolve once all iterations of the interval complete.
|
|
56
|
-
*
|
|
57
|
-
* @example
|
|
58
|
-
* <example module="intervalExample" name="interval-service">
|
|
59
|
-
* <file name="index.html">
|
|
60
|
-
* <script>
|
|
61
|
-
* angular.module('intervalExample', [])
|
|
62
|
-
* .controller('ExampleController', ['$scope', '$interval',
|
|
63
|
-
* function($scope, $interval) {
|
|
64
|
-
* $scope.format = 'M/d/yy h:mm:ss a';
|
|
65
|
-
* $scope.blood_1 = 100;
|
|
66
|
-
* $scope.blood_2 = 120;
|
|
67
|
-
*
|
|
68
|
-
* let stop;
|
|
69
|
-
* $scope.fight = function() {
|
|
70
|
-
* // Don't start a new fight if we are already fighting
|
|
71
|
-
* if ( angular.isDefined(stop) ) return;
|
|
72
|
-
*
|
|
73
|
-
* stop = $interval(function() {
|
|
74
|
-
* if ($scope.blood_1 > 0 && $scope.blood_2 > 0) {
|
|
75
|
-
* $scope.blood_1 = $scope.blood_1 - 3;
|
|
76
|
-
* $scope.blood_2 = $scope.blood_2 - 4;
|
|
77
|
-
* } else {
|
|
78
|
-
* $scope.stopFight();
|
|
79
|
-
* }
|
|
80
|
-
* }, 100);
|
|
81
|
-
* };
|
|
82
|
-
*
|
|
83
|
-
* $scope.stopFight = function() {
|
|
84
|
-
* if (angular.isDefined(stop)) {
|
|
85
|
-
* $interval.cancel(stop);
|
|
86
|
-
* stop = undefined;
|
|
87
|
-
* }
|
|
88
|
-
* };
|
|
89
|
-
*
|
|
90
|
-
* $scope.resetFight = function() {
|
|
91
|
-
* $scope.blood_1 = 100;
|
|
92
|
-
* $scope.blood_2 = 120;
|
|
93
|
-
* };
|
|
94
|
-
*
|
|
95
|
-
* $scope.$on('$destroy', function() {
|
|
96
|
-
* // Make sure that the interval is destroyed too
|
|
97
|
-
* $scope.stopFight();
|
|
98
|
-
* });
|
|
99
|
-
* }])
|
|
100
|
-
* // Register the 'myCurrentTime' directive factory method.
|
|
101
|
-
* // We inject $interval and dateFilter service since the factory method is DI.
|
|
102
|
-
* .directive('myCurrentTime', ['$interval', 'dateFilter',
|
|
103
|
-
* function($interval, dateFilter) {
|
|
104
|
-
* // return the directive link function. (compile function not needed)
|
|
105
|
-
* return function(scope, element, attrs) {
|
|
106
|
-
* let format, // date format
|
|
107
|
-
* stopTime; // so that we can cancel the time updates
|
|
108
|
-
*
|
|
109
|
-
* // used to update the UI
|
|
110
|
-
* function updateTime() {
|
|
111
|
-
* element.text(dateFilter(new Date(), format));
|
|
112
|
-
* }
|
|
113
|
-
*
|
|
114
|
-
* // watch the expression, and update the UI on change.
|
|
115
|
-
* scope.$watch(attrs.myCurrentTime, function(value) {
|
|
116
|
-
* format = value;
|
|
117
|
-
* updateTime();
|
|
118
|
-
* });
|
|
119
|
-
*
|
|
120
|
-
* stopTime = $interval(updateTime, 1000);
|
|
121
|
-
*
|
|
122
|
-
* // listen on DOM destroy (removal) event, and cancel the next UI update
|
|
123
|
-
* // to prevent updating time after the DOM element was removed.
|
|
124
|
-
* element.on('$destroy', function() {
|
|
125
|
-
* $interval.cancel(stopTime);
|
|
126
|
-
* });
|
|
127
|
-
* }
|
|
128
|
-
* }]);
|
|
129
|
-
* </script>
|
|
130
|
-
*
|
|
131
|
-
* <div>
|
|
132
|
-
* <div ng-controller="ExampleController">
|
|
133
|
-
* <label>Date format: <input ng-model="format"></label> <hr/>
|
|
134
|
-
* Current time is: <span my-current-time="format"></span>
|
|
135
|
-
* <hr/>
|
|
136
|
-
* Blood 1 : <font color='red'>{{blood_1}}</font>
|
|
137
|
-
* Blood 2 : <font color='red'>{{blood_2}}</font>
|
|
138
|
-
* <button type="button" data-ng-click="fight()">Fight</button>
|
|
139
|
-
* <button type="button" data-ng-click="stopFight()">StopFight</button>
|
|
140
|
-
* <button type="button" data-ng-click="resetFight()">resetFight</button>
|
|
141
|
-
* </div>
|
|
142
|
-
* </div>
|
|
143
|
-
*
|
|
144
|
-
* </file>
|
|
145
|
-
* </example>
|
|
146
|
-
*/
|
|
147
21
|
const interval = $$intervalFactory(setIntervalFn, clearIntervalFn);
|
|
148
22
|
|
|
149
23
|
/**
|
|
@@ -0,0 +1,122 @@
|
|
|
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
|
+
* function($scope, $interval) {
|
|
42
|
+
* $scope.format = 'M/d/yy h:mm:ss a';
|
|
43
|
+
* $scope.blood_1 = 100;
|
|
44
|
+
* $scope.blood_2 = 120;
|
|
45
|
+
*
|
|
46
|
+
* let stop;
|
|
47
|
+
* $scope.fight = function() {
|
|
48
|
+
* // Don't start a new fight if we are already fighting
|
|
49
|
+
* if ( angular.isDefined(stop) ) return;
|
|
50
|
+
*
|
|
51
|
+
* stop = $interval(function() {
|
|
52
|
+
* if ($scope.blood_1 > 0 && $scope.blood_2 > 0) {
|
|
53
|
+
* $scope.blood_1 = $scope.blood_1 - 3;
|
|
54
|
+
* $scope.blood_2 = $scope.blood_2 - 4;
|
|
55
|
+
* } else {
|
|
56
|
+
* $scope.stopFight();
|
|
57
|
+
* }
|
|
58
|
+
* }, 100);
|
|
59
|
+
* };
|
|
60
|
+
*
|
|
61
|
+
* $scope.stopFight = function() {
|
|
62
|
+
* if (angular.isDefined(stop)) {
|
|
63
|
+
* $interval.cancel(stop);
|
|
64
|
+
* stop = undefined;
|
|
65
|
+
* }
|
|
66
|
+
* };
|
|
67
|
+
*
|
|
68
|
+
* $scope.resetFight = function() {
|
|
69
|
+
* $scope.blood_1 = 100;
|
|
70
|
+
* $scope.blood_2 = 120;
|
|
71
|
+
* };
|
|
72
|
+
*
|
|
73
|
+
* $scope.$on('$destroy', function() {
|
|
74
|
+
* // Make sure that the interval is destroyed too
|
|
75
|
+
* $scope.stopFight();
|
|
76
|
+
* });
|
|
77
|
+
* }])
|
|
78
|
+
_ // Register the 'myCurrentTime' directive factory method.
|
|
79
|
+
_ // We inject $interval and dateFilter service since the factory method is DI.
|
|
80
|
+
* .directive('myCurrentTime', ['$interval', 'dateFilter',
|
|
81
|
+
_ function($interval, dateFilter) {
|
|
82
|
+
_ // return the directive link function. (compile function not needed)
|
|
83
|
+
_ return function(scope, element, attrs) {
|
|
84
|
+
_ let format, // date format
|
|
85
|
+
_ stopTime; // so that we can cancel the time updates
|
|
86
|
+
_
|
|
87
|
+
_ // used to update the UI
|
|
88
|
+
_ function updateTime() {
|
|
89
|
+
_ element.text(dateFilter(new Date(), format));
|
|
90
|
+
_ } \*
|
|
91
|
+
_ // watch the expression, and update the UI on change.
|
|
92
|
+
_ scope.$watch(attrs.myCurrentTime, function(value) {
|
|
93
|
+
* format = value;
|
|
94
|
+
* updateTime();
|
|
95
|
+
* });
|
|
96
|
+
*
|
|
97
|
+
* stopTime = $interval(updateTime, 1000);
|
|
98
|
+
*
|
|
99
|
+
* // listen on DOM destroy (removal) event, and cancel the next UI update
|
|
100
|
+
* // to prevent updating time after the DOM element was removed.
|
|
101
|
+
* element.on('$destroy', function() {
|
|
102
|
+
_ $interval.cancel(stopTime);
|
|
103
|
+
_ });
|
|
104
|
+
_ }
|
|
105
|
+
_ }]);
|
|
106
|
+
_ </script>
|
|
107
|
+
_
|
|
108
|
+
_ <div>
|
|
109
|
+
_ <div ng-controller="ExampleController">
|
|
110
|
+
_ <label>Date format: <input ng-model="format"></label> <hr/>
|
|
111
|
+
_ Current time is: <span my-current-time="format"></span>
|
|
112
|
+
_ <hr/>
|
|
113
|
+
_ Blood 1 : <font color='red'>{{blood_1}}</font>
|
|
114
|
+
_ Blood 2 : <font color='red'>{{blood_2}}</font>
|
|
115
|
+
_ <button type="button" data-ng-click="fight()">Fight</button>
|
|
116
|
+
_ <button type="button" data-ng-click="stopFight()">StopFight</button>
|
|
117
|
+
_ <button type="button" data-ng-click="resetFight()">resetFight</button>
|
|
118
|
+
_ </div>
|
|
119
|
+
_ </div> \*
|
|
120
|
+
_ </file>
|
|
121
|
+
_ </example>
|
|
122
|
+
\*/
|
package/src/core/location.js
CHANGED
|
@@ -10,7 +10,6 @@ import {
|
|
|
10
10
|
isString,
|
|
11
11
|
isUndefined,
|
|
12
12
|
minErr,
|
|
13
|
-
nodeName_,
|
|
14
13
|
parseKeyValue,
|
|
15
14
|
toInt,
|
|
16
15
|
toKeyValue,
|
|
@@ -932,7 +931,7 @@ export function $LocationProvider() {
|
|
|
932
931
|
let elm = jqLite(event.target);
|
|
933
932
|
|
|
934
933
|
// traverse the DOM up to find first A tag
|
|
935
|
-
while (
|
|
934
|
+
while (elm[0].nodeName.toLowerCase() !== "a") {
|
|
936
935
|
// ignore rewriting if no A tag (reached root element, or no parent - removed from document)
|
|
937
936
|
if (elm[0] === $rootElement[0] || !(elm = elm.parent())[0]) return;
|
|
938
937
|
}
|