@angular-wave/angular.ts 0.0.38 → 0.0.39
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/Makefile +6 -5
- package/dist/angular-ts.esm.js +2 -1
- package/dist/angular-ts.umd.js +1 -1
- package/package.json +2 -4
- package/rollup.config.js +5 -1
- package/src/core/scope/scope.js +4 -7
- package/src/index.js +307 -1
- package/src/loader.js +13 -6
- package/src/public.js +7 -2
- package/src/src.test.js +10 -0
- package/tsconfig.json +1 -1
- package/tsconfig.types.json +11 -0
- package/types/animations/animate-cache.d.ts +7 -7
- package/types/animations/animate-children-directive.d.ts +3 -6
- package/types/animations/animate-swap.d.ts +7 -16
- package/types/animations/animation.d.ts +2 -11
- package/types/animations/raf-scheduler.d.ts +3 -3
- package/types/animations/shared.d.ts +8 -23
- package/types/core/{animate-css.d.ts → animate/animate-css.d.ts} +2 -8
- package/types/core/{cache.d.ts → cache/cache.d.ts} +5 -5
- package/types/core/compile/compile.d.ts +173 -0
- package/types/core/controller/controller.d.ts +32 -0
- package/types/core/exception-handler.d.ts +1 -1
- package/types/core/filter/filter.d.ts +9 -0
- package/types/core/{interpolate.d.ts → interpolate/interpolate.d.ts} +23 -39
- package/types/core/interval/interval-factory.d.ts +4 -0
- package/types/core/{interval.d.ts → interval/interval.d.ts} +1 -1
- package/types/core/location/location.d.ts +209 -0
- package/types/core/pubsub/pubsub.d.ts +156 -0
- package/types/core/q/q.d.ts +31 -0
- package/types/core/sanitize/sanitize-uri.d.ts +53 -0
- package/types/core/{sce.d.ts → sce/sce.d.ts} +80 -86
- package/types/core/scope/scope.d.ts +727 -0
- package/types/core/task-tracker-factory.d.ts +29 -29
- package/types/core/timeout/timeout.d.ts +20 -0
- package/types/core/{urlUtils.d.ts → url-utils/url-utils.d.ts} +2 -7
- package/types/directive/{bind.d.ts → bind/bind.d.ts} +4 -10
- package/types/directive/{class.d.ts → class/class.d.ts} +12 -21
- package/types/directive/controller/controller.d.ts +6 -0
- package/types/directive/events/events.d.ts +5 -0
- package/types/directive/form/form.d.ts +200 -0
- package/types/directive/if/if.d.ts +8 -0
- package/types/directive/include/include.d.ts +14 -0
- package/types/directive/{input.d.ts → input/input.d.ts} +20 -69
- package/types/directive/{model.d.ts → model/model.d.ts} +256 -279
- package/types/directive/options/options.d.ts +9 -0
- package/types/directive/ref/ref.d.ts +5 -0
- package/types/directive/repeat/repeat.d.ts +8 -0
- package/types/directive/{script.d.ts → script/script.d.ts} +5 -8
- package/types/directive/{show-hide.d.ts → show-hide/show-hide.d.ts} +10 -16
- package/types/directive/switch/switch.d.ts +17 -0
- package/types/directive/transclude/transclude.d.ts +4 -0
- package/types/directive/{validators.d.ts → validators/validators.d.ts} +20 -35
- package/types/filters/filters.d.ts +10 -16
- package/types/filters/order-by.d.ts +2 -4
- package/types/index.d.ts +117 -0
- package/types/injector.d.ts +12 -0
- package/types/public.d.ts +5 -0
- package/types/router/common/coreservices.d.ts +2 -2
- package/types/router/common/glob.d.ts +9 -9
- package/types/router/common/queue.d.ts +13 -13
- package/types/router/common/trace.d.ts +43 -43
- package/types/router/directives/view-directive.d.ts +13 -32
- package/types/router/globals.d.ts +20 -20
- package/types/router/hooks/lazy-load.d.ts +2 -11
- package/types/router/hooks/redirect-to.d.ts +1 -4
- package/types/router/hooks/url.d.ts +1 -5
- package/types/router/hooks/views.d.ts +1 -4
- package/types/router/params/param-factory.d.ts +5 -5
- package/types/router/params/param-type.d.ts +35 -35
- package/types/router/params/param-types.d.ts +11 -11
- package/types/router/params/param.d.ts +38 -38
- package/types/router/params/state-params.d.ts +10 -10
- package/types/router/path/path-node.d.ts +34 -34
- package/types/router/path/path-utils.d.ts +73 -77
- package/types/router/resolve/resolvable.d.ts +32 -32
- package/types/router/resolve/resolve-context.d.ts +84 -84
- package/types/router/services.d.ts +4 -9
- package/types/router/state/state-builder.d.ts +27 -27
- package/types/router/state/state-matcher.d.ts +5 -5
- package/types/router/state/state-object.d.ts +58 -58
- package/types/router/state/state-queue-manager.d.ts +10 -16
- package/types/router/state/state-registry.d.ts +100 -107
- package/types/router/state/state-service.d.ts +411 -411
- package/types/router/state/target-state.d.ts +64 -69
- package/types/router/state/views.d.ts +31 -37
- package/types/router/state-filters.d.ts +7 -7
- package/types/router/state-provider.d.ts +105 -105
- package/types/router/template-factory.d.ts +83 -112
- package/types/router/transition/hook-builder.d.ts +25 -25
- package/types/router/transition/hook-registry.d.ts +68 -83
- package/types/router/transition/interface.d.ts +7 -7
- package/types/router/transition/reject-factory.d.ts +34 -34
- package/types/router/transition/transition-event-type.d.ts +9 -18
- package/types/router/transition/transition-hook.d.ts +77 -82
- package/types/router/transition/transition-service.d.ts +82 -99
- package/types/router/transition/transition.d.ts +369 -377
- package/types/router/url/url-config.d.ts +84 -84
- package/types/router/url/url-matcher.d.ts +115 -119
- package/types/router/url/url-rule.d.ts +114 -124
- package/types/router/url/url-rules.d.ts +217 -217
- package/types/router/url/url-service.d.ts +264 -269
- package/types/router/view/view.d.ts +114 -117
- package/types/router/view-scroll.d.ts +2 -2
- package/types/services/anchor-scroll.d.ts +2 -8
- package/types/services/browser.d.ts +122 -130
- package/types/services/cache-factory.d.ts +25 -25
- package/types/services/cookie-reader.d.ts +2 -2
- package/types/services/document.d.ts +2 -2
- package/types/services/http/http.d.ts +145 -0
- package/types/services/{http-backend.d.ts → http-backend/http-backend.d.ts} +3 -35
- package/types/services/log.d.ts +49 -49
- package/types/services/template-request.d.ts +44 -53
- package/types/shared/common.d.ts +4 -19
- package/types/{constants.d.ts → shared/constants.d.ts} +6 -6
- package/types/shared/hof.d.ts +1 -1
- package/types/{jqLite.d.ts → shared/jqlite/jqlite.d.ts} +11 -11
- package/types/shared/test-utils.d.ts +11 -0
- package/types/shared/utils.d.ts +7 -24
- package/types-back/global.d.ts +3 -1
- package/types-back/index.d.ts +2 -221
- package/types/core/compile.d.ts +0 -206
- package/types/core/controller.d.ts +0 -42
- package/types/core/filter.d.ts +0 -9
- package/types/core/interval-factory.d.ts +0 -21
- package/types/core/location.d.ts +0 -234
- package/types/core/pubsub.d.ts +0 -164
- package/types/core/q.d.ts +0 -33
- package/types/core/root-scope.d.ts +0 -754
- package/types/core/sanitize-uri.d.ts +0 -57
- package/types/core/timeout.d.ts +0 -31
- package/types/directive/controller.d.ts +0 -6
- package/types/directive/events.d.ts +0 -12
- package/types/directive/form.d.ts +0 -230
- package/types/directive/if.d.ts +0 -17
- package/types/directive/include.d.ts +0 -33
- package/types/directive/options.d.ts +0 -16
- package/types/directive/ref.d.ts +0 -11
- package/types/directive/repeat.d.ts +0 -23
- package/types/directive/switch.d.ts +0 -23
- package/types/directive/transclude.d.ts +0 -15
- package/types/services/http.d.ts +0 -157
- /package/types/directive/{attrs.d.ts → attrs/attrs.d.ts} +0 -0
- /package/types/directive/{change.d.ts → change/change.d.ts} +0 -0
- /package/types/directive/{cloak.d.ts → cloak/cloak.d.ts} +0 -0
- /package/types/directive/{init.d.ts → init/init.d.ts} +0 -0
- /package/types/directive/{list.d.ts → list/list.d.ts} +0 -0
- /package/types/directive/{non-bindable.d.ts → non-bindable/non-bindable.d.ts} +0 -0
- /package/types/directive/{style.d.ts → style/style.d.ts} +0 -0
- /package/types/exts/{aria.d.ts → aria/aria.d.ts} +0 -0
- /package/types/exts/{messages.d.ts → messages/messages.d.ts} +0 -0
|
@@ -0,0 +1,727 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Counts all the watchers of direct and indirect child scopes of the current scope.
|
|
3
|
+
*
|
|
4
|
+
* The watchers of the current scope are included in the count and so are all the watchers of
|
|
5
|
+
* isolate child scopes.
|
|
6
|
+
* @param {Scope} scope
|
|
7
|
+
* @returns {number} Total number of watchers.
|
|
8
|
+
*/
|
|
9
|
+
export function countWatchers(scope: Scope): number;
|
|
10
|
+
/**
|
|
11
|
+
* Counts all the direct and indirect child scopes of the current scope.
|
|
12
|
+
*
|
|
13
|
+
* The current scope is excluded from the count. The count includes all isolate child scopes.
|
|
14
|
+
* @param {Scope} scope
|
|
15
|
+
* @returns {number} Total number of child scopes.
|
|
16
|
+
*/
|
|
17
|
+
export function countChildScopes(scope: Scope): number;
|
|
18
|
+
export type ScopePhase = number;
|
|
19
|
+
export namespace ScopePhase {
|
|
20
|
+
let NONE: number;
|
|
21
|
+
let APPLY: number;
|
|
22
|
+
let DIGEST: number;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The number of digest iterations
|
|
26
|
+
*/
|
|
27
|
+
export type TTL = number;
|
|
28
|
+
/**
|
|
29
|
+
* @typedef {Object} AsyncQueueTask
|
|
30
|
+
* @property {Scope} scope
|
|
31
|
+
* @property {Function} fn
|
|
32
|
+
* @property {Object} locals
|
|
33
|
+
*/
|
|
34
|
+
/**
|
|
35
|
+
*
|
|
36
|
+
* The default number of `$digest` iterations the scope should attempt to execute before giving up and
|
|
37
|
+
* assuming that the model is unstable. In complex applications it's possible that the dependencies between `$watch`s will result in
|
|
38
|
+
* several digest iterations.
|
|
39
|
+
*
|
|
40
|
+
* @typedef {number} TTL The number of digest iterations
|
|
41
|
+
*
|
|
42
|
+
* @type {TTL}
|
|
43
|
+
*/
|
|
44
|
+
export const TTL: TTL;
|
|
45
|
+
/** @type {AsyncQueueTask[]} */
|
|
46
|
+
export const $$asyncQueue: AsyncQueueTask[];
|
|
47
|
+
export const $$postDigestQueue: any[];
|
|
48
|
+
export const $$applyAsyncQueue: any[];
|
|
49
|
+
/**
|
|
50
|
+
* Provider responsible for instantiating the initial scope, aka - root scope.
|
|
51
|
+
* Every application has a single root {@link ng.$rootScope.Scope scope}.
|
|
52
|
+
* All other scopes are descendant scopes of the root scope. Scopes provide separation
|
|
53
|
+
* between the model and the view, via a mechanism for watching the model for changes.
|
|
54
|
+
* They also provide event emission/broadcast and subscription facility. See the
|
|
55
|
+
* {@link guide/scope developer guide on scopes}.
|
|
56
|
+
*
|
|
57
|
+
* The provider also injects runtime services to make them available to all scopes.
|
|
58
|
+
*
|
|
59
|
+
*/
|
|
60
|
+
export class $RootScopeProvider {
|
|
61
|
+
$get: (string | ((exceptionHandler: angular.IExceptionHandlerService, parse: angular.IParseService, browser: any) => Scope))[];
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* DESIGN NOTES
|
|
65
|
+
*
|
|
66
|
+
* The design decisions behind the scope are heavily favored for speed and memory consumption.
|
|
67
|
+
*
|
|
68
|
+
* The typical use of scope is to watch the expressions, which most of the time return the same
|
|
69
|
+
* value as last time so we optimize the operation.
|
|
70
|
+
*
|
|
71
|
+
* Closures construction is expensive in terms of speed as well as memory:
|
|
72
|
+
* - No closures, instead use prototypical inheritance for API
|
|
73
|
+
* - Internal state needs to be stored on scope directly, which means that private state is
|
|
74
|
+
* exposed as $$____ properties
|
|
75
|
+
*
|
|
76
|
+
* Loop operations are optimized by using while(count--) { ... }
|
|
77
|
+
* - This means that in order to keep the same order of execution as addition we have to add
|
|
78
|
+
* items to the array at the beginning (unshift) instead of at the end (push)
|
|
79
|
+
*
|
|
80
|
+
* Child scopes are created and removed often
|
|
81
|
+
* - Using an array would be slow since inserts in the middle are expensive; so we use linked lists
|
|
82
|
+
*
|
|
83
|
+
* There are fewer watches than observers. This is why you don't want the observer to be implemented
|
|
84
|
+
* in the same way as watch. Watch requires return of the initialization function which is expensive
|
|
85
|
+
* to construct.
|
|
86
|
+
*/
|
|
87
|
+
export class Scope {
|
|
88
|
+
/**
|
|
89
|
+
* @type {number} Unique scope ID (monotonically increasing) useful for debugging.
|
|
90
|
+
*/
|
|
91
|
+
$id: number;
|
|
92
|
+
/** @type {ScopePhase} */
|
|
93
|
+
$$phase: ScopePhase;
|
|
94
|
+
/**
|
|
95
|
+
* @type {?Scope} Reference to the parent scope.
|
|
96
|
+
*/
|
|
97
|
+
$parent: Scope | null;
|
|
98
|
+
/**
|
|
99
|
+
* @type {?Scope}
|
|
100
|
+
*/
|
|
101
|
+
$root: Scope | null;
|
|
102
|
+
/**
|
|
103
|
+
* @type {[]}
|
|
104
|
+
*/
|
|
105
|
+
$$watchers: [];
|
|
106
|
+
/**
|
|
107
|
+
* @type {number}
|
|
108
|
+
*/
|
|
109
|
+
$$digestWatchIndex: number;
|
|
110
|
+
/**
|
|
111
|
+
* @type {?Scope}
|
|
112
|
+
*/
|
|
113
|
+
$$nextSibling: Scope | null;
|
|
114
|
+
/**
|
|
115
|
+
* @type {?Scope}
|
|
116
|
+
*/
|
|
117
|
+
$$prevSibling: Scope | null;
|
|
118
|
+
/**
|
|
119
|
+
* @type {?Scope}
|
|
120
|
+
*/
|
|
121
|
+
$$childHead: Scope | null;
|
|
122
|
+
/**
|
|
123
|
+
* @type {?Scope}
|
|
124
|
+
*/
|
|
125
|
+
$$childTail: Scope | null;
|
|
126
|
+
/** @type {boolean} */
|
|
127
|
+
$$destroyed: boolean;
|
|
128
|
+
/** @type {boolean} */
|
|
129
|
+
$$suspended: boolean;
|
|
130
|
+
/** @type {object} */
|
|
131
|
+
$$listeners: object;
|
|
132
|
+
/** @type {object} */
|
|
133
|
+
$$listenerCount: object;
|
|
134
|
+
/** @type {number} */
|
|
135
|
+
$$watchersCount: number;
|
|
136
|
+
$$isolateBindings: any;
|
|
137
|
+
/**
|
|
138
|
+
* @type {?Scope}
|
|
139
|
+
*/
|
|
140
|
+
$$ChildScope: Scope | null;
|
|
141
|
+
/**
|
|
142
|
+
* Creates a new child {@link Scope}.
|
|
143
|
+
*
|
|
144
|
+
* The parent scope will propagate the {@link ng.$rootScope.Scope#$digest $digest()} event.
|
|
145
|
+
* The scope can be removed from the scope hierarchy using {@link ng.$rootScope.Scope#$destroy $destroy()}.
|
|
146
|
+
*
|
|
147
|
+
* {@link ng.$rootScope.Scope#$destroy $destroy()} must be called on a scope when it is
|
|
148
|
+
* desired for the scope and its child scopes to be permanently detached from the parent and
|
|
149
|
+
* thus stop participating in model change detection and listener notification by invoking.
|
|
150
|
+
*
|
|
151
|
+
* @param {?boolean} isolate If true, then the scope does not prototypically inherit from the
|
|
152
|
+
* parent scope. The scope is isolated, as it can not see parent scope properties.
|
|
153
|
+
* When creating widgets, it is useful for the widget to not accidentally read parent
|
|
154
|
+
* state.
|
|
155
|
+
*
|
|
156
|
+
* @param {?Scope} [parent=this] The {@link ng.$rootScope.Scope `Scope`} that will be the `$parent`
|
|
157
|
+
* of the newly created scope. Defaults to `this` scope if not provided.
|
|
158
|
+
* This is used when creating a transclude scope to correctly place it
|
|
159
|
+
* in the scope hierarchy while maintaining the correct prototypical
|
|
160
|
+
* inheritance.
|
|
161
|
+
*
|
|
162
|
+
* @returns {Scope} The newly created child scope.
|
|
163
|
+
*
|
|
164
|
+
*/
|
|
165
|
+
$new(isolate: boolean | null, parent?: Scope | null): Scope;
|
|
166
|
+
/**
|
|
167
|
+
* @ngdoc method
|
|
168
|
+
* @name $rootScope.Scope#$watch
|
|
169
|
+
* @kind function
|
|
170
|
+
*
|
|
171
|
+
* @description
|
|
172
|
+
* Registers a `listener` callback to be executed whenever the `watchExpression` changes.
|
|
173
|
+
*
|
|
174
|
+
* - The `watchExpression` is called on every call to {@link ng.$rootScope.Scope#$digest
|
|
175
|
+
* $digest()} and should return the value that will be watched. (`watchExpression` should not change
|
|
176
|
+
* its value when executed multiple times with the same input because it may be executed multiple
|
|
177
|
+
* times by {@link ng.$rootScope.Scope#$digest $digest()}. That is, `watchExpression` should be
|
|
178
|
+
* [idempotent](http://en.wikipedia.org/wiki/Idempotence).)
|
|
179
|
+
* - The `listener` is called only when the value from the current `watchExpression` and the
|
|
180
|
+
* previous call to `watchExpression` are not equal (with the exception of the initial run,
|
|
181
|
+
* see below). Inequality is determined according to reference inequality,
|
|
182
|
+
* [strict comparison](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators)
|
|
183
|
+
* via the `!==` Javascript operator, unless `objectEquality == true`
|
|
184
|
+
* (see next point)
|
|
185
|
+
* - When `objectEquality == true`, inequality of the `watchExpression` is determined
|
|
186
|
+
* according to the {@link angular.equals} function. To save the value of the object for
|
|
187
|
+
* later comparison, the {@link structuredClone} function is used. This therefore means that
|
|
188
|
+
* watching complex objects will have adverse memory and performance implications.
|
|
189
|
+
* - This should not be used to watch for changes in objects that are (or contain)
|
|
190
|
+
* [File](https://developer.mozilla.org/docs/Web/API/File) objects due to limitations with {@link structuredClone `structuredClone`}.
|
|
191
|
+
* - The watch `listener` may change the model, which may trigger other `listener`s to fire.
|
|
192
|
+
* This is achieved by rerunning the watchers until no changes are detected. The rerun
|
|
193
|
+
* iteration limit is 10 to prevent an infinite loop deadlock.
|
|
194
|
+
*
|
|
195
|
+
*
|
|
196
|
+
* If you want to be notified whenever {@link ng.$rootScope.Scope#$digest $digest} is called,
|
|
197
|
+
* you can register a `watchExpression` function with no `listener`. (Be prepared for
|
|
198
|
+
* multiple calls to your `watchExpression` because it will execute multiple times in a
|
|
199
|
+
* single {@link ng.$rootScope.Scope#$digest $digest} cycle if a change is detected.)
|
|
200
|
+
*
|
|
201
|
+
* After a watcher is registered with the scope, the `listener` fn is called asynchronously
|
|
202
|
+
* (via {@link ng.$rootScope.Scope#$evalAsync $evalAsync}) to initialize the
|
|
203
|
+
* watcher. In rare cases, this is undesirable because the listener is called when the result
|
|
204
|
+
* of `watchExpression` didn't change. To detect this scenario within the `listener` fn, you
|
|
205
|
+
* can compare the `newVal` and `oldVal`. If these two values are identical (`===`) then the
|
|
206
|
+
* listener was called due to initialization.
|
|
207
|
+
*
|
|
208
|
+
*
|
|
209
|
+
*
|
|
210
|
+
* @example
|
|
211
|
+
* ```js
|
|
212
|
+
// let's assume that scope was dependency injected as the $rootScope
|
|
213
|
+
let scope = $rootScope;
|
|
214
|
+
scope.name = 'misko';
|
|
215
|
+
scope.counter = 0;
|
|
216
|
+
|
|
217
|
+
expect(scope.counter).toEqual(0);
|
|
218
|
+
scope.$watch('name', function(newValue, oldValue) {
|
|
219
|
+
scope.counter = scope.counter + 1;
|
|
220
|
+
});
|
|
221
|
+
expect(scope.counter).toEqual(0);
|
|
222
|
+
|
|
223
|
+
scope.$digest();
|
|
224
|
+
// the listener is always called during the first $digest loop after it was registered
|
|
225
|
+
expect(scope.counter).toEqual(1);
|
|
226
|
+
|
|
227
|
+
scope.$digest();
|
|
228
|
+
// but now it will not be called unless the value changes
|
|
229
|
+
expect(scope.counter).toEqual(1);
|
|
230
|
+
|
|
231
|
+
scope.name = 'adam';
|
|
232
|
+
scope.$digest();
|
|
233
|
+
expect(scope.counter).toEqual(2);
|
|
234
|
+
|
|
235
|
+
// Using a function as a watchExpression
|
|
236
|
+
let food;
|
|
237
|
+
scope.foodCounter = 0;
|
|
238
|
+
expect(scope.foodCounter).toEqual(0);
|
|
239
|
+
scope.$watch(
|
|
240
|
+
// This function returns the value being watched. It is called for each turn of the $digest loop
|
|
241
|
+
function() { return food; },
|
|
242
|
+
// This is the change listener, called when the value returned from the above function changes
|
|
243
|
+
function(newValue, oldValue) {
|
|
244
|
+
if ( newValue !== oldValue ) {
|
|
245
|
+
// Only increment the counter if the value changed
|
|
246
|
+
scope.foodCounter = scope.foodCounter + 1;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
);
|
|
250
|
+
// No digest has been run so the counter will be zero
|
|
251
|
+
expect(scope.foodCounter).toEqual(0);
|
|
252
|
+
|
|
253
|
+
// Run the digest but since food has not changed count will still be zero
|
|
254
|
+
scope.$digest();
|
|
255
|
+
expect(scope.foodCounter).toEqual(0);
|
|
256
|
+
|
|
257
|
+
// Update food and run digest. Now the counter will increment
|
|
258
|
+
food = 'cheeseburger';
|
|
259
|
+
scope.$digest();
|
|
260
|
+
expect(scope.foodCounter).toEqual(1);
|
|
261
|
+
|
|
262
|
+
* ```
|
|
263
|
+
*
|
|
264
|
+
*
|
|
265
|
+
*
|
|
266
|
+
* @param {string | ((scope: Scope) => any)} watchExp Expression that is evaluated on each
|
|
267
|
+
* {@link ng.$rootScope.Scope#$digest $digest} cycle. A change in the return value triggers
|
|
268
|
+
* a call to the `listener`.
|
|
269
|
+
*
|
|
270
|
+
* - `string`: Evaluated as {@link guide/expression expression}
|
|
271
|
+
* - `function(scope)`: called with current `scope` as a parameter.
|
|
272
|
+
* @param {(newVal: any, oldVal: any, scope: Scope) => any} listener Callback called whenever the value
|
|
273
|
+
* of `watchExpression` changes.
|
|
274
|
+
*
|
|
275
|
+
* - `newVal` contains the current value of the `watchExpression`
|
|
276
|
+
* - `oldVal` contains the previous value of the `watchExpression`
|
|
277
|
+
* - `scope` refers to the current scope
|
|
278
|
+
* @param {boolean=} [objectEquality=false] Compare for object equality using {@link angular.equals} instead of
|
|
279
|
+
* comparing for reference equality.
|
|
280
|
+
* @returns {function()} Returns a deregistration function for this listener.
|
|
281
|
+
*/
|
|
282
|
+
$watch(watchExp: string | ((scope: Scope) => any), listener: (newVal: any, oldVal: any, scope: Scope) => any, objectEquality?: boolean | undefined): () => any;
|
|
283
|
+
/**
|
|
284
|
+
* @ngdoc method
|
|
285
|
+
* @name $rootScope.Scope#$watchGroup
|
|
286
|
+
* @kind function
|
|
287
|
+
*
|
|
288
|
+
* @description
|
|
289
|
+
* A variant of {@link ng.$rootScope.Scope#$watch $watch()} where it watches an array of `watchExpressions`.
|
|
290
|
+
* If any one expression in the collection changes the `listener` is executed.
|
|
291
|
+
*
|
|
292
|
+
* - The items in the `watchExpressions` array are observed via the standard `$watch` operation. Their return
|
|
293
|
+
* values are examined for changes on every call to `$digest`.
|
|
294
|
+
* - The `listener` is called whenever any expression in the `watchExpressions` array changes.
|
|
295
|
+
*
|
|
296
|
+
* @param {Array.<string|Function(scope)>} watchExpressions Array of expressions that will be individually
|
|
297
|
+
* watched using {@link ng.$rootScope.Scope#$watch $watch()}
|
|
298
|
+
*
|
|
299
|
+
* @param {function(newValues, oldValues, scope)} listener Callback called whenever the return value of any
|
|
300
|
+
* expression in `watchExpressions` changes
|
|
301
|
+
* The `newValues` array contains the current values of the `watchExpressions`, with the indexes matching
|
|
302
|
+
* those of `watchExpression`
|
|
303
|
+
* and the `oldValues` array contains the previous values of the `watchExpressions`, with the indexes matching
|
|
304
|
+
* those of `watchExpression`
|
|
305
|
+
* The `scope` refers to the current scope.
|
|
306
|
+
* @returns {function()} Returns a de-registration function for all listeners.
|
|
307
|
+
*/
|
|
308
|
+
$watchGroup(watchExpressions: any, listener: (arg0: any[], arg1: any[], arg2: scope) => any): () => any;
|
|
309
|
+
/**
|
|
310
|
+
* @ngdoc method
|
|
311
|
+
* @name $rootScope.Scope#$watchCollection
|
|
312
|
+
* @kind function
|
|
313
|
+
*
|
|
314
|
+
* @description
|
|
315
|
+
* Shallow watches the properties of an object and fires whenever any of the properties change
|
|
316
|
+
* (for arrays, this implies watching the array items; for object maps, this implies watching
|
|
317
|
+
* the properties). If a change is detected, the `listener` callback is fired.
|
|
318
|
+
*
|
|
319
|
+
* - The `obj` collection is observed via standard $watch operation and is examined on every
|
|
320
|
+
* call to $digest() to see if any items have been added, removed, or moved.
|
|
321
|
+
* - The `listener` is called whenever anything within the `obj` has changed. Examples include
|
|
322
|
+
* adding, removing, and moving items belonging to an object or array.
|
|
323
|
+
*
|
|
324
|
+
*
|
|
325
|
+
*
|
|
326
|
+
*
|
|
327
|
+
* @param {string|function(scope)} obj Evaluated as {@link guide/expression expression}. The
|
|
328
|
+
* expression value should evaluate to an object or an array which is observed on each
|
|
329
|
+
* {@link ng.$rootScope.Scope#$digest $digest} cycle. Any shallow change within the
|
|
330
|
+
* collection will trigger a call to the `listener`.
|
|
331
|
+
*
|
|
332
|
+
* @param {function(newCollection, oldCollection, scope)} listener a callback function called
|
|
333
|
+
* when a change is detected.
|
|
334
|
+
* - The `newCollection` object is the newly modified data obtained from the `obj` expression
|
|
335
|
+
* - The `oldCollection` object is a copy of the former collection data.
|
|
336
|
+
* Due to performance considerations, the`oldCollection` value is computed only if the
|
|
337
|
+
* `listener` function declares two or more arguments.
|
|
338
|
+
* - The `scope` argument refers to the current scope.
|
|
339
|
+
*
|
|
340
|
+
* @returns {function()} Returns a de-registration function for this listener. When the
|
|
341
|
+
* de-registration function is executed, the internal watch operation is terminated.
|
|
342
|
+
*/
|
|
343
|
+
$watchCollection(obj: string | ((arg0: scope) => any), listener: (arg0: newCollection, arg1: oldCollection, arg2: scope) => any): () => any;
|
|
344
|
+
/**
|
|
345
|
+
* @ngdoc method
|
|
346
|
+
* @name $rootScope.Scope#$digest
|
|
347
|
+
* @kind function
|
|
348
|
+
*
|
|
349
|
+
* @description
|
|
350
|
+
* Processes all of the {@link ng.$rootScope.Scope#$watch watchers} of the current scope and
|
|
351
|
+
* its children. Because a {@link ng.$rootScope.Scope#$watch watcher}'s listener can change
|
|
352
|
+
* the model, the `$digest()` keeps calling the {@link ng.$rootScope.Scope#$watch watchers}
|
|
353
|
+
* until no more listeners are firing. This means that it is possible to get into an infinite
|
|
354
|
+
* loop. This function will throw `'Maximum iteration limit exceeded.'` if the number of
|
|
355
|
+
* iterations exceeds 10.
|
|
356
|
+
*
|
|
357
|
+
* Usually, you don't call `$digest()` directly in
|
|
358
|
+
* {@link ng.directive:ngController controllers} or in
|
|
359
|
+
* {@link ng.$compileProvider#directive directives}.
|
|
360
|
+
* Instead, you should call {@link ng.$rootScope.Scope#$apply $apply()} (typically from within
|
|
361
|
+
* a {@link ng.$compileProvider#directive directive}), which will force a `$digest()`.
|
|
362
|
+
*
|
|
363
|
+
* If you want to be notified whenever `$digest()` is called,
|
|
364
|
+
* you can register a `watchExpression` function with
|
|
365
|
+
* {@link ng.$rootScope.Scope#$watch $watch()} with no `listener`.
|
|
366
|
+
*
|
|
367
|
+
* In unit tests, you may need to call `$digest()` to simulate the scope life cycle.
|
|
368
|
+
*
|
|
369
|
+
* @example
|
|
370
|
+
* ```js
|
|
371
|
+
let scope = ...;
|
|
372
|
+
scope.name = 'misko';
|
|
373
|
+
scope.counter = 0;
|
|
374
|
+
|
|
375
|
+
expect(scope.counter).toEqual(0);
|
|
376
|
+
scope.$watch('name', function(newValue, oldValue) {
|
|
377
|
+
scope.counter = scope.counter + 1;
|
|
378
|
+
});
|
|
379
|
+
expect(scope.counter).toEqual(0);
|
|
380
|
+
|
|
381
|
+
scope.$digest();
|
|
382
|
+
// the listener is always called during the first $digest loop after it was registered
|
|
383
|
+
expect(scope.counter).toEqual(1);
|
|
384
|
+
|
|
385
|
+
scope.$digest();
|
|
386
|
+
// but now it will not be called unless the value changes
|
|
387
|
+
expect(scope.counter).toEqual(1);
|
|
388
|
+
|
|
389
|
+
scope.name = 'adam';
|
|
390
|
+
scope.$digest();
|
|
391
|
+
expect(scope.counter).toEqual(2);
|
|
392
|
+
* ```
|
|
393
|
+
*
|
|
394
|
+
*/
|
|
395
|
+
$digest(): void;
|
|
396
|
+
/**
|
|
397
|
+
* @private
|
|
398
|
+
* @param {ScopePhase} phase
|
|
399
|
+
*/
|
|
400
|
+
private beginPhase;
|
|
401
|
+
/**
|
|
402
|
+
* @ngdoc method
|
|
403
|
+
* @name $rootScope.Scope#$suspend
|
|
404
|
+
* @kind function
|
|
405
|
+
*
|
|
406
|
+
* @description
|
|
407
|
+
* Suspend watchers of this scope subtree so that they will not be invoked during digest.
|
|
408
|
+
*
|
|
409
|
+
* This can be used to optimize your application when you know that running those watchers
|
|
410
|
+
* is redundant.
|
|
411
|
+
*
|
|
412
|
+
* **Warning**
|
|
413
|
+
*
|
|
414
|
+
* Suspending scopes from the digest cycle can have unwanted and difficult to debug results.
|
|
415
|
+
* Only use this approach if you are confident that you know what you are doing and have
|
|
416
|
+
* ample tests to ensure that bindings get updated as you expect.
|
|
417
|
+
*
|
|
418
|
+
* Some of the things to consider are:
|
|
419
|
+
*
|
|
420
|
+
* * Any external event on a directive/component will not trigger a digest while the hosting
|
|
421
|
+
* scope is suspended - even if the event handler calls `$apply()` or `$rootScope.$digest()`.
|
|
422
|
+
* * Transcluded content exists on a scope that inherits from outside a directive but exists
|
|
423
|
+
* as a child of the directive's containing scope. If the containing scope is suspended the
|
|
424
|
+
* transcluded scope will also be suspended, even if the scope from which the transcluded
|
|
425
|
+
* scope inherits is not suspended.
|
|
426
|
+
* * Multiple directives trying to manage the suspended status of a scope can confuse each other:
|
|
427
|
+
* * A call to `$suspend()` on an already suspended scope is a no-op.
|
|
428
|
+
* * A call to `$resume()` on a non-suspended scope is a no-op.
|
|
429
|
+
* * If two directives suspend a scope, then one of them resumes the scope, the scope will no
|
|
430
|
+
* longer be suspended. This could result in the other directive believing a scope to be
|
|
431
|
+
* suspended when it is not.
|
|
432
|
+
* * If a parent scope is suspended then all its descendants will be also excluded from future
|
|
433
|
+
* digests whether or not they have been suspended themselves. Note that this also applies to
|
|
434
|
+
* isolate child scopes.
|
|
435
|
+
* * Calling `$digest()` directly on a descendant of a suspended scope will still run the watchers
|
|
436
|
+
* for that scope and its descendants. When digesting we only check whether the current scope is
|
|
437
|
+
* locally suspended, rather than checking whether it has a suspended ancestor.
|
|
438
|
+
* * Calling `$resume()` on a scope that has a suspended ancestor will not cause the scope to be
|
|
439
|
+
* included in future digests until all its ancestors have been resumed.
|
|
440
|
+
* * Resolved promises, e.g. from explicit `$q` deferreds and `$http` calls, trigger `$apply()`
|
|
441
|
+
* against the `$rootScope` and so will still trigger a global digest even if the promise was
|
|
442
|
+
* initiated by a component that lives on a suspended scope.
|
|
443
|
+
*/
|
|
444
|
+
$suspend(): void;
|
|
445
|
+
/**
|
|
446
|
+
* @ngdoc method
|
|
447
|
+
* @name $rootScope.Scope#$isSuspended
|
|
448
|
+
* @kind function
|
|
449
|
+
*
|
|
450
|
+
* @description
|
|
451
|
+
* Call this method to determine if this scope has been explicitly suspended. It will not
|
|
452
|
+
* tell you whether an ancestor has been suspended.
|
|
453
|
+
* To determine if this scope will be excluded from a digest triggered at the $rootScope,
|
|
454
|
+
* for example, you must check all its ancestors:
|
|
455
|
+
*
|
|
456
|
+
* ```
|
|
457
|
+
* function isExcludedFromDigest(scope) {
|
|
458
|
+
* while(scope) {
|
|
459
|
+
* if (scope.$isSuspended()) return true;
|
|
460
|
+
* scope = scope.$parent;
|
|
461
|
+
* }
|
|
462
|
+
* return false;
|
|
463
|
+
* ```
|
|
464
|
+
*
|
|
465
|
+
* Be aware that a scope may not be included in digests if it has a suspended ancestor,
|
|
466
|
+
* even if `$isSuspended()` returns false.
|
|
467
|
+
*
|
|
468
|
+
* @returns true if the current scope has been suspended.
|
|
469
|
+
*/
|
|
470
|
+
$isSuspended(): boolean;
|
|
471
|
+
/**
|
|
472
|
+
* @ngdoc method
|
|
473
|
+
* @name $rootScope.Scope#$resume
|
|
474
|
+
* @kind function
|
|
475
|
+
*
|
|
476
|
+
* @description
|
|
477
|
+
* Resume watchers of this scope subtree in case it was suspended.
|
|
478
|
+
*
|
|
479
|
+
* See {@link $rootScope.Scope#$suspend} for information about the dangers of using this approach.
|
|
480
|
+
*/
|
|
481
|
+
$resume(): void;
|
|
482
|
+
/**
|
|
483
|
+
* @ngdoc event
|
|
484
|
+
* @name $rootScope.Scope#$destroy
|
|
485
|
+
* @eventType broadcast on scope being destroyed
|
|
486
|
+
*
|
|
487
|
+
* @description
|
|
488
|
+
* Broadcasted when a scope and its children are being destroyed.
|
|
489
|
+
*
|
|
490
|
+
* Note that, in AngularTS, there is also a `$destroy` jQuery event, which can be used to
|
|
491
|
+
* clean up DOM bindings before an element is removed from the DOM.
|
|
492
|
+
*/
|
|
493
|
+
/**
|
|
494
|
+
* @ngdoc method
|
|
495
|
+
* @name $rootScope.Scope#$destroy
|
|
496
|
+
* @kind function
|
|
497
|
+
*
|
|
498
|
+
* @description
|
|
499
|
+
* Removes the current scope (and all of its children) from the parent scope. Removal implies
|
|
500
|
+
* that calls to {@link ng.$rootScope.Scope#$digest $digest()} will no longer
|
|
501
|
+
* propagate to the current scope and its children. Removal also implies that the current
|
|
502
|
+
* scope is eligible for garbage collection.
|
|
503
|
+
*
|
|
504
|
+
* The `$destroy()` is usually used by directives such as
|
|
505
|
+
* {@link ng.directive:ngRepeat ngRepeat} for managing the
|
|
506
|
+
* unrolling of the loop.
|
|
507
|
+
*
|
|
508
|
+
* Just before a scope is destroyed, a `$destroy` event is broadcasted on this scope.
|
|
509
|
+
* Application code can register a `$destroy` event handler that will give it a chance to
|
|
510
|
+
* perform any necessary cleanup.
|
|
511
|
+
*
|
|
512
|
+
* Note that, in AngularTS, there is also a `$destroy` event, which can be used to
|
|
513
|
+
* clean up DOM bindings before an element is removed from the DOM.
|
|
514
|
+
*/
|
|
515
|
+
$destroy(): void;
|
|
516
|
+
/**
|
|
517
|
+
* @ngdoc method
|
|
518
|
+
* @name $rootScope.Scope#$apply
|
|
519
|
+
* @kind function
|
|
520
|
+
*
|
|
521
|
+
* @description
|
|
522
|
+
* `$apply()` is used to execute an expression in AngularTS from outside of the AngularTS
|
|
523
|
+
* framework. (For example from browser DOM events, setTimeout, XHR or third party libraries).
|
|
524
|
+
* Because we are calling into the AngularTS framework we need to perform proper scope life
|
|
525
|
+
* cycle of {@link ng.$exceptionHandler exception handling},
|
|
526
|
+
* {@link ng.$rootScope.Scope#$digest executing watches}.
|
|
527
|
+
*
|
|
528
|
+
* **Life cycle: Pseudo-Code of `$apply()`**
|
|
529
|
+
*
|
|
530
|
+
* ```js
|
|
531
|
+
function $apply(expr) {
|
|
532
|
+
try {
|
|
533
|
+
return $eval(expr);
|
|
534
|
+
} catch (e) {
|
|
535
|
+
$exceptionHandler(e);
|
|
536
|
+
} finally {
|
|
537
|
+
$root.$digest();
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
* ```
|
|
541
|
+
*
|
|
542
|
+
*
|
|
543
|
+
* Scope's `$apply()` method transitions through the following stages:
|
|
544
|
+
*
|
|
545
|
+
* 1. The {@link guide/expression expression} is executed using the
|
|
546
|
+
* {@link ng.$rootScope.Scope#$eval $eval()} method.
|
|
547
|
+
* 2. Any exceptions from the execution of the expression are forwarded to the
|
|
548
|
+
* {@link ng.$exceptionHandler $exceptionHandler} service.
|
|
549
|
+
* 3. The {@link ng.$rootScope.Scope#$watch watch} listeners are fired immediately after the
|
|
550
|
+
* expression was executed using the {@link ng.$rootScope.Scope#$digest $digest()} method.
|
|
551
|
+
*
|
|
552
|
+
*
|
|
553
|
+
* @param {string|function(Scope): any} [expr] An AngularTS expression to be executed.
|
|
554
|
+
*
|
|
555
|
+
* - `string`: execute using the rules as defined in {@link guide/expression expression}.
|
|
556
|
+
* - `function(scope)`: execute the function with current `scope` parameter.
|
|
557
|
+
*
|
|
558
|
+
* @returns {*} The result of evaluating the expression.
|
|
559
|
+
*/
|
|
560
|
+
$apply(expr?: string | ((arg0: Scope) => any)): any;
|
|
561
|
+
/**
|
|
562
|
+
* @ngdoc method
|
|
563
|
+
* @name $rootScope.Scope#$evalAsync
|
|
564
|
+
* @kind function
|
|
565
|
+
*
|
|
566
|
+
* @description
|
|
567
|
+
* Executes the expression on the current scope at a later point in time.
|
|
568
|
+
*
|
|
569
|
+
* The `$evalAsync` makes no guarantees as to when the `expression` will be executed, only
|
|
570
|
+
* that:
|
|
571
|
+
*
|
|
572
|
+
* - it will execute after the function that scheduled the evaluation (preferably before DOM
|
|
573
|
+
* rendering).
|
|
574
|
+
* - at least one {@link ng.$rootScope.Scope#$digest $digest cycle} will be performed after
|
|
575
|
+
* `expression` execution.
|
|
576
|
+
*
|
|
577
|
+
* Any exceptions from the execution of the expression are forwarded to the
|
|
578
|
+
* {@link ng.$exceptionHandler $exceptionHandler} service.
|
|
579
|
+
*
|
|
580
|
+
* __Note:__ if this function is called outside of a `$digest` cycle, a new `$digest` cycle
|
|
581
|
+
* will be scheduled. However, it is encouraged to always call code that changes the model
|
|
582
|
+
* from within an `$apply` call. That includes code evaluated via `$evalAsync`.
|
|
583
|
+
*
|
|
584
|
+
* @param {(string|function())=} expr An AngularTS expression to be executed.
|
|
585
|
+
*
|
|
586
|
+
* - `string`: execute using the rules as defined in {@link guide/expression expression}.
|
|
587
|
+
* - `function(scope)`: execute the function with the current `scope` parameter.
|
|
588
|
+
*
|
|
589
|
+
* @param {(object)=} locals Local variables object, useful for overriding values in scope.
|
|
590
|
+
*/
|
|
591
|
+
$evalAsync(expr?: (string | (() => any)) | undefined, locals?: (object) | undefined): any;
|
|
592
|
+
/**
|
|
593
|
+
* @ngdoc method
|
|
594
|
+
* @name $rootScope.Scope#$applyAsync
|
|
595
|
+
* @kind function
|
|
596
|
+
*
|
|
597
|
+
* @description
|
|
598
|
+
* Schedule the invocation of $apply to occur at a later time. The actual time difference
|
|
599
|
+
* varies across browsers, but is typically around ~10 milliseconds.
|
|
600
|
+
*
|
|
601
|
+
* This can be used to queue up multiple expressions which need to be evaluated in the same
|
|
602
|
+
* digest.
|
|
603
|
+
*
|
|
604
|
+
* @param {(string|function())=} expr An AngularTS expression to be executed.
|
|
605
|
+
*
|
|
606
|
+
* - `string`: execute using the rules as defined in {@link guide/expression expression}.
|
|
607
|
+
* - `function(scope)`: execute the function with current `scope` parameter.
|
|
608
|
+
*/
|
|
609
|
+
$applyAsync(expr?: (string | (() => any)) | undefined): void;
|
|
610
|
+
/**
|
|
611
|
+
* @description
|
|
612
|
+
* Listens on events of a given type. See {@link ng.$rootScope.Scope#$emit $emit} for
|
|
613
|
+
* discussion of event life cycle.
|
|
614
|
+
*
|
|
615
|
+
* The event listener function format is: `function(event, args...)`. The `event` object
|
|
616
|
+
* passed into the listener has the following attributes:
|
|
617
|
+
*
|
|
618
|
+
* - `targetScope` - `{Scope}`: the scope on which the event was `$emit`-ed or
|
|
619
|
+
* `$broadcast`-ed.
|
|
620
|
+
* - `currentScope` - `{Scope}`: the scope that is currently handling the event. Once the
|
|
621
|
+
* event propagates through the scope hierarchy, this property is set to null.
|
|
622
|
+
* - `name` - `{string}`: name of the event.
|
|
623
|
+
* - `stopPropagation` - `{function=}`: calling `stopPropagation` function will cancel
|
|
624
|
+
* further event propagation (available only for events that were `$emit`-ed).
|
|
625
|
+
* - `preventDefault` - `{function}`: calling `preventDefault` sets `defaultPrevented` flag
|
|
626
|
+
* to true.
|
|
627
|
+
* - `defaultPrevented` - `{boolean}`: true if `preventDefault` was called.
|
|
628
|
+
*
|
|
629
|
+
* @param {string} name Event name to listen on.
|
|
630
|
+
* @param {function(angular.IAngularEvent): any} listener Function to call when the event is emitted.
|
|
631
|
+
* @returns {function()} Returns a deregistration function for this listener.
|
|
632
|
+
*/
|
|
633
|
+
$on(name: string, listener: (arg0: angular.IAngularEvent) => any): () => any;
|
|
634
|
+
/**
|
|
635
|
+
* @ngdoc method
|
|
636
|
+
* @name $rootScope.Scope#$eval
|
|
637
|
+
* @kind function
|
|
638
|
+
*
|
|
639
|
+
* @description
|
|
640
|
+
* Executes the `expression` on the current scope and returns the result. Any exceptions in
|
|
641
|
+
* the expression are propagated (uncaught). This is useful when evaluating AngularTS
|
|
642
|
+
* expressions.
|
|
643
|
+
*
|
|
644
|
+
* @example
|
|
645
|
+
* ```js
|
|
646
|
+
let scope = new Scope();
|
|
647
|
+
scope.a = 1;
|
|
648
|
+
scope.b = 2;
|
|
649
|
+
|
|
650
|
+
expect(scope.$eval('a+b')).toEqual(3);
|
|
651
|
+
expect(scope.$eval(function(scope){ return scope.a + scope.b; })).toEqual(3);
|
|
652
|
+
* ```
|
|
653
|
+
*
|
|
654
|
+
* @param {string|function(Scope): any} [expr] An AngularTS expression to be executed.
|
|
655
|
+
*
|
|
656
|
+
* - `string`: execute using the rules as defined in {@link guide/expression expression}.
|
|
657
|
+
* - `function(scope)`: execute the function with the current `scope` parameter.
|
|
658
|
+
*
|
|
659
|
+
* @param {(object)=} locals Local variables object, useful for overriding values in scope.
|
|
660
|
+
* @returns {*} The result of evaluating the expression.
|
|
661
|
+
*/
|
|
662
|
+
$eval(expr?: string | ((arg0: Scope) => any), locals?: (object) | undefined): any;
|
|
663
|
+
/**
|
|
664
|
+
* @private
|
|
665
|
+
*/
|
|
666
|
+
private $$postDigest;
|
|
667
|
+
clearPhase(): void;
|
|
668
|
+
/**
|
|
669
|
+
* @param {number} count
|
|
670
|
+
*/
|
|
671
|
+
incrementWatchersCount(count: number): void;
|
|
672
|
+
/**
|
|
673
|
+
* @param {number} count
|
|
674
|
+
* @param {string} name
|
|
675
|
+
*/
|
|
676
|
+
decrementListenerCount(count: number, name: string): void;
|
|
677
|
+
/**
|
|
678
|
+
* @ngdoc method
|
|
679
|
+
* @name $rootScope.Scope#$emit
|
|
680
|
+
* @kind function
|
|
681
|
+
*
|
|
682
|
+
* @description
|
|
683
|
+
* Dispatches an event `name` upwards through the scope hierarchy notifying the
|
|
684
|
+
* registered {@link ng.$rootScope.Scope#$on} listeners.
|
|
685
|
+
*
|
|
686
|
+
* The event life cycle starts at the scope on which `$emit` was called. All
|
|
687
|
+
* {@link ng.$rootScope.Scope#$on listeners} listening for `name` event on this scope get
|
|
688
|
+
* notified. Afterwards, the event traverses upwards toward the root scope and calls all
|
|
689
|
+
* registered listeners along the way. The event will stop propagating if one of the listeners
|
|
690
|
+
* cancels it.
|
|
691
|
+
*
|
|
692
|
+
* Any exception emitted from the {@link ng.$rootScope.Scope#$on listeners} will be passed
|
|
693
|
+
* onto the {@link ng.$exceptionHandler $exceptionHandler} service.
|
|
694
|
+
*
|
|
695
|
+
* @param {string} name Event name to emit.
|
|
696
|
+
* @param {...*} args Optional one or more arguments which will be passed onto the event listeners.
|
|
697
|
+
* @return {Object} Event object (see {@link ng.$rootScope.Scope#$on}).
|
|
698
|
+
*/
|
|
699
|
+
$emit(name: string, ...args: any[]): any;
|
|
700
|
+
/**
|
|
701
|
+
* @ngdoc method
|
|
702
|
+
* @name $rootScope.Scope#$broadcast
|
|
703
|
+
* @kind function
|
|
704
|
+
*
|
|
705
|
+
* @description
|
|
706
|
+
* Dispatches an event `name` downwards to all child scopes (and their children) notifying the
|
|
707
|
+
* registered {@link ng.$rootScope.Scope#$on} listeners.
|
|
708
|
+
*
|
|
709
|
+
* The event life cycle starts at the scope on which `$broadcast` was called. All
|
|
710
|
+
* {@link ng.$rootScope.Scope#$on listeners} listening for `name` event on this scope get
|
|
711
|
+
* notified. Afterwards, the event propagates to all direct and indirect scopes of the current
|
|
712
|
+
* scope and calls all registered listeners along the way. The event cannot be canceled.
|
|
713
|
+
*
|
|
714
|
+
* Any exception emitted from the {@link ng.$rootScope.Scope#$on listeners} will be passed
|
|
715
|
+
* onto the {@link ng.$exceptionHandler $exceptionHandler} service.
|
|
716
|
+
*
|
|
717
|
+
* @param {string} name Event name to broadcast.
|
|
718
|
+
* @param {...*} args Optional one or more arguments which will be passed onto the event listeners.
|
|
719
|
+
* @return {Object} Event object, see {@link ng.$rootScope.Scope#$on}
|
|
720
|
+
*/
|
|
721
|
+
$broadcast(name: string, ...args: any[]): any;
|
|
722
|
+
}
|
|
723
|
+
export type AsyncQueueTask = {
|
|
724
|
+
scope: Scope;
|
|
725
|
+
fn: Function;
|
|
726
|
+
locals: any;
|
|
727
|
+
};
|