@angular-wave/angular.ts 0.0.1
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/.eslintignore +1 -0
- package/.eslintrc.cjs +29 -0
- package/.github/workflows/playwright.yml +27 -0
- package/CHANGELOG.md +17974 -0
- package/CODE_OF_CONDUCT.md +3 -0
- package/CONTRIBUTING.md +246 -0
- package/DEVELOPERS.md +488 -0
- package/LICENSE +22 -0
- package/Makefile +31 -0
- package/README.md +115 -0
- package/RELEASE.md +98 -0
- package/SECURITY.md +16 -0
- package/TRIAGING.md +135 -0
- package/css/angular.css +22 -0
- package/dist/angular-ts.cjs.js +36843 -0
- package/dist/angular-ts.esm.js +36841 -0
- package/dist/angular-ts.umd.js +36848 -0
- package/dist/build/angular-animate.js +4272 -0
- package/dist/build/angular-aria.js +426 -0
- package/dist/build/angular-message-format.js +1072 -0
- package/dist/build/angular-messages.js +829 -0
- package/dist/build/angular-mocks.js +3757 -0
- package/dist/build/angular-parse-ext.js +1275 -0
- package/dist/build/angular-resource.js +911 -0
- package/dist/build/angular-route.js +1266 -0
- package/dist/build/angular-sanitize.js +891 -0
- package/dist/build/angular-touch.js +368 -0
- package/dist/build/angular.js +36600 -0
- package/e2e/unit.spec.ts +15 -0
- package/images/android-chrome-192x192.png +0 -0
- package/images/android-chrome-512x512.png +0 -0
- package/images/apple-touch-icon.png +0 -0
- package/images/favicon-16x16.png +0 -0
- package/images/favicon-32x32.png +0 -0
- package/images/favicon.ico +0 -0
- package/images/site.webmanifest +1 -0
- package/index.html +104 -0
- package/package.json +47 -0
- package/playwright.config.ts +78 -0
- package/public/circle.html +1 -0
- package/public/my_child_directive.html +1 -0
- package/public/my_directive.html +1 -0
- package/public/my_other_directive.html +1 -0
- package/public/test.html +1 -0
- package/rollup.config.js +31 -0
- package/src/animations/animateCache.js +55 -0
- package/src/animations/animateChildrenDirective.js +105 -0
- package/src/animations/animateCss.js +1139 -0
- package/src/animations/animateCssDriver.js +291 -0
- package/src/animations/animateJs.js +367 -0
- package/src/animations/animateJsDriver.js +67 -0
- package/src/animations/animateQueue.js +851 -0
- package/src/animations/animation.js +506 -0
- package/src/animations/module.js +779 -0
- package/src/animations/ngAnimateSwap.js +119 -0
- package/src/animations/rafScheduler.js +50 -0
- package/src/animations/shared.js +378 -0
- package/src/constants.js +20 -0
- package/src/core/animate.js +845 -0
- package/src/core/animateCss.js +73 -0
- package/src/core/animateRunner.js +195 -0
- package/src/core/attributes.js +199 -0
- package/src/core/cache.js +45 -0
- package/src/core/compile.js +4727 -0
- package/src/core/controller.js +225 -0
- package/src/core/exceptionHandler.js +63 -0
- package/src/core/filter.js +146 -0
- package/src/core/interpolate.js +442 -0
- package/src/core/interval.js +188 -0
- package/src/core/intervalFactory.js +57 -0
- package/src/core/location.js +1086 -0
- package/src/core/parser/parse.js +2562 -0
- package/src/core/parser/parse.md +13 -0
- package/src/core/q.js +746 -0
- package/src/core/rootScope.js +1596 -0
- package/src/core/sanitizeUri.js +85 -0
- package/src/core/sce.js +1161 -0
- package/src/core/taskTrackerFactory.js +125 -0
- package/src/core/timeout.js +121 -0
- package/src/core/urlUtils.js +187 -0
- package/src/core/utils.js +1349 -0
- package/src/directive/a.js +37 -0
- package/src/directive/attrs.js +283 -0
- package/src/directive/bind.js +51 -0
- package/src/directive/bind.md +142 -0
- package/src/directive/change.js +12 -0
- package/src/directive/change.md +25 -0
- package/src/directive/cloak.js +12 -0
- package/src/directive/cloak.md +24 -0
- package/src/directive/events.js +75 -0
- package/src/directive/events.md +166 -0
- package/src/directive/form.js +725 -0
- package/src/directive/init.js +15 -0
- package/src/directive/init.md +41 -0
- package/src/directive/input.js +1783 -0
- package/src/directive/list.js +46 -0
- package/src/directive/list.md +22 -0
- package/src/directive/ngClass.js +249 -0
- package/src/directive/ngController.js +64 -0
- package/src/directive/ngCsp.js +82 -0
- package/src/directive/ngIf.js +134 -0
- package/src/directive/ngInclude.js +217 -0
- package/src/directive/ngModel.js +1356 -0
- package/src/directive/ngModelOptions.js +509 -0
- package/src/directive/ngOptions.js +670 -0
- package/src/directive/ngRef.js +90 -0
- package/src/directive/ngRepeat.js +650 -0
- package/src/directive/ngShowHide.js +255 -0
- package/src/directive/ngSwitch.js +178 -0
- package/src/directive/ngTransclude.js +98 -0
- package/src/directive/non-bindable.js +11 -0
- package/src/directive/non-bindable.md +17 -0
- package/src/directive/script.js +30 -0
- package/src/directive/select.js +624 -0
- package/src/directive/style.js +25 -0
- package/src/directive/style.md +23 -0
- package/src/directive/validators.js +329 -0
- package/src/exts/aria.js +544 -0
- package/src/exts/messages.js +852 -0
- package/src/filters/filter.js +207 -0
- package/src/filters/filter.md +69 -0
- package/src/filters/filters.js +239 -0
- package/src/filters/json.md +16 -0
- package/src/filters/limit-to.js +43 -0
- package/src/filters/limit-to.md +19 -0
- package/src/filters/order-by.js +183 -0
- package/src/filters/order-by.md +83 -0
- package/src/index.js +13 -0
- package/src/injector.js +1034 -0
- package/src/jqLite.js +1117 -0
- package/src/loader.js +1320 -0
- package/src/public.js +215 -0
- package/src/routeToRegExp.js +41 -0
- package/src/services/anchorScroll.js +135 -0
- package/src/services/browser.js +321 -0
- package/src/services/cacheFactory.js +398 -0
- package/src/services/cookieReader.js +72 -0
- package/src/services/document.js +64 -0
- package/src/services/http.js +1537 -0
- package/src/services/httpBackend.js +206 -0
- package/src/services/log.js +160 -0
- package/src/services/templateRequest.js +139 -0
- package/test/angular.spec.js +2153 -0
- package/test/aria/aria.spec.js +1245 -0
- package/test/binding.spec.js +504 -0
- package/test/build-test.html +14 -0
- package/test/injector.spec.js +2327 -0
- package/test/jasmine/jasmine-5.1.2/boot0.js +65 -0
- package/test/jasmine/jasmine-5.1.2/boot1.js +133 -0
- package/test/jasmine/jasmine-5.1.2/jasmine-html.js +963 -0
- package/test/jasmine/jasmine-5.1.2/jasmine.css +320 -0
- package/test/jasmine/jasmine-5.1.2/jasmine.js +10824 -0
- package/test/jasmine/jasmine-5.1.2/jasmine_favicon.png +0 -0
- package/test/jasmine/jasmine-browser.json +17 -0
- package/test/jasmine/jasmine.json +9 -0
- package/test/jqlite.spec.js +2133 -0
- package/test/loader.spec.js +219 -0
- package/test/messages/messages.spec.js +1146 -0
- package/test/min-err.spec.js +174 -0
- package/test/mock-test.html +13 -0
- package/test/module-test.html +15 -0
- package/test/ng/anomate.spec.js +606 -0
- package/test/ng/cache-factor.spec.js +334 -0
- package/test/ng/compile.spec.js +17956 -0
- package/test/ng/controller-provider.spec.js +227 -0
- package/test/ng/cookie-reader.spec.js +98 -0
- package/test/ng/directive/a.spec.js +192 -0
- package/test/ng/directive/bind.spec.js +334 -0
- package/test/ng/directive/boolean.spec.js +136 -0
- package/test/ng/directive/change.spec.js +71 -0
- package/test/ng/directive/class.spec.js +858 -0
- package/test/ng/directive/click.spec.js +38 -0
- package/test/ng/directive/cloak.spec.js +44 -0
- package/test/ng/directive/constoller.spec.js +194 -0
- package/test/ng/directive/element-style.spec.js +92 -0
- package/test/ng/directive/event.spec.js +282 -0
- package/test/ng/directive/form.spec.js +1518 -0
- package/test/ng/directive/href.spec.js +143 -0
- package/test/ng/directive/if.spec.js +402 -0
- package/test/ng/directive/include.spec.js +828 -0
- package/test/ng/directive/init.spec.js +68 -0
- package/test/ng/directive/input.spec.js +3810 -0
- package/test/ng/directive/list.spec.js +170 -0
- package/test/ng/directive/model-options.spec.js +1008 -0
- package/test/ng/directive/model.spec.js +1905 -0
- package/test/ng/directive/non-bindable.spec.js +55 -0
- package/test/ng/directive/options.spec.js +3583 -0
- package/test/ng/directive/ref.spec.js +575 -0
- package/test/ng/directive/repeat.spec.js +1675 -0
- package/test/ng/directive/script.spec.js +52 -0
- package/test/ng/directive/scrset.spec.js +67 -0
- package/test/ng/directive/select.spec.js +2541 -0
- package/test/ng/directive/show-hide.spec.js +253 -0
- package/test/ng/directive/src.spec.js +157 -0
- package/test/ng/directive/style.spec.js +178 -0
- package/test/ng/directive/switch.spec.js +647 -0
- package/test/ng/directive/validators.spec.js +717 -0
- package/test/ng/document.spec.js +52 -0
- package/test/ng/filter/filter.spec.js +714 -0
- package/test/ng/filter/filters.spec.js +35 -0
- package/test/ng/filter/limit-to.spec.js +251 -0
- package/test/ng/filter/order-by.spec.js +891 -0
- package/test/ng/filter.spec.js +149 -0
- package/test/ng/http-backend.spec.js +398 -0
- package/test/ng/http.spec.js +4071 -0
- package/test/ng/interpolate.spec.js +642 -0
- package/test/ng/interval.spec.js +343 -0
- package/test/ng/location.spec.js +3488 -0
- package/test/ng/on.spec.js +229 -0
- package/test/ng/parse.spec.js +4655 -0
- package/test/ng/prop.spec.js +805 -0
- package/test/ng/q.spec.js +2904 -0
- package/test/ng/root-element.spec.js +16 -0
- package/test/ng/sanitize-uri.spec.js +249 -0
- package/test/ng/sce.spec.js +660 -0
- package/test/ng/scope.spec.js +3442 -0
- package/test/ng/template-request.spec.js +236 -0
- package/test/ng/timeout.spec.js +351 -0
- package/test/ng/url-utils.spec.js +156 -0
- package/test/ng/utils.spec.js +144 -0
- package/test/original-test.html +21 -0
- package/test/public.spec.js +34 -0
- package/test/sanitize/bing-html.spec.js +36 -0
- package/test/server/express.js +158 -0
- package/test/test-utils.js +11 -0
- package/tsconfig.json +17 -0
- package/types/angular.d.ts +138 -0
- package/types/global.d.ts +9 -0
- package/types/index.d.ts +2357 -0
- package/types/jqlite.d.ts +558 -0
- package/vite.config.js +14 -0
package/src/loader.js
ADDED
|
@@ -0,0 +1,1320 @@
|
|
|
1
|
+
import {
|
|
2
|
+
minErr,
|
|
3
|
+
extend,
|
|
4
|
+
forEach,
|
|
5
|
+
getNgAttribute,
|
|
6
|
+
isFunction,
|
|
7
|
+
isObject,
|
|
8
|
+
ngAttrPrefixes,
|
|
9
|
+
isDefined,
|
|
10
|
+
isArray,
|
|
11
|
+
isDate,
|
|
12
|
+
isElement,
|
|
13
|
+
isNumber,
|
|
14
|
+
isString,
|
|
15
|
+
isUndefined,
|
|
16
|
+
merge,
|
|
17
|
+
bind,
|
|
18
|
+
fromJson,
|
|
19
|
+
toJson,
|
|
20
|
+
identity,
|
|
21
|
+
equals,
|
|
22
|
+
assertNotHasOwnProperty,
|
|
23
|
+
isBoolean,
|
|
24
|
+
isValidObjectMaxDepth,
|
|
25
|
+
minErrConfig,
|
|
26
|
+
} from "./core/utils";
|
|
27
|
+
import { jqLite, startingTag } from "./jqLite";
|
|
28
|
+
import { createInjector } from "./injector";
|
|
29
|
+
import { CACHE } from "./core/cache";
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @ngdoc module
|
|
33
|
+
* @name ng
|
|
34
|
+
|
|
35
|
+
* @installation
|
|
36
|
+
* @description
|
|
37
|
+
*
|
|
38
|
+
* The ng module is loaded by default when an AngularJS application is started. The module itself
|
|
39
|
+
* contains the essential components for an AngularJS application to function. The table below
|
|
40
|
+
* lists a high level breakdown of each of the services/factories, filters, directives and testing
|
|
41
|
+
* components available within this core module.
|
|
42
|
+
*
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
const ngMinErr = minErr("ng");
|
|
46
|
+
|
|
47
|
+
/** @type {Object.<string, angular.IModule>} */
|
|
48
|
+
const moduleCache = {};
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* @type {ng.IAngularStatic}
|
|
52
|
+
*/
|
|
53
|
+
export class Angular {
|
|
54
|
+
constructor() {
|
|
55
|
+
this.cache = CACHE;
|
|
56
|
+
this.element = undefined;
|
|
57
|
+
this.version = {
|
|
58
|
+
full: "",
|
|
59
|
+
major: 0,
|
|
60
|
+
minor: 0,
|
|
61
|
+
dot: 0,
|
|
62
|
+
codeName: "",
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
// Utility methods kept for backwards purposes
|
|
66
|
+
this.bind = bind;
|
|
67
|
+
this.equals = equals;
|
|
68
|
+
this.element = jqLite;
|
|
69
|
+
this.extend = extend;
|
|
70
|
+
this.forEach = forEach;
|
|
71
|
+
this.fromJson = fromJson;
|
|
72
|
+
this.toJson = toJson;
|
|
73
|
+
this.identity = identity;
|
|
74
|
+
this.isArray = isArray;
|
|
75
|
+
this.isDate = isDate;
|
|
76
|
+
this.isDefined = isDefined;
|
|
77
|
+
this.isElement = isElement;
|
|
78
|
+
this.isFunction = isFunction;
|
|
79
|
+
this.isNumber = isNumber;
|
|
80
|
+
this.isObject = isObject;
|
|
81
|
+
this.isString = isString;
|
|
82
|
+
this.isUndefined = isUndefined;
|
|
83
|
+
this.merge = merge;
|
|
84
|
+
this.noop = () => {};
|
|
85
|
+
this.errorHandlingConfig = errorHandlingConfig;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* @module angular
|
|
90
|
+
* @function bootstrap
|
|
91
|
+
|
|
92
|
+
* @description
|
|
93
|
+
* Use this function to manually start up AngularJS application.
|
|
94
|
+
*
|
|
95
|
+
* For more information, see the {@link guide/bootstrap Bootstrap guide}.
|
|
96
|
+
*
|
|
97
|
+
* AngularJS will detect if it has been loaded into the browser more than once and only allow the
|
|
98
|
+
* first loaded script to be bootstrapped and will report a warning to the browser console for
|
|
99
|
+
* each of the subsequent scripts. This prevents strange results in applications, where otherwise
|
|
100
|
+
* multiple instances of AngularJS try to work on the DOM.
|
|
101
|
+
*
|
|
102
|
+
* <div class="alert alert-warning">
|
|
103
|
+
* **Note:** Protractor based end-to-end tests cannot use this function to bootstrap manually.
|
|
104
|
+
* They must use {@link ng.directive:ngApp ngApp}.
|
|
105
|
+
* </div>
|
|
106
|
+
*
|
|
107
|
+
* <div class="alert alert-warning">
|
|
108
|
+
* **Note:** Do not bootstrap the app on an element with a directive that uses {@link ng.$compile#transclusion transclusion},
|
|
109
|
+
* such as {@link ng.ngIf `ngIf`}, {@link ng.ngInclude `ngInclude`} and {@link ngRoute.ngView `ngView`}.
|
|
110
|
+
* Doing this misplaces the app {@link ng.$rootElement `$rootElement`} and the app's {@link auto.$injector injector},
|
|
111
|
+
* causing animations to stop working and making the injector inaccessible from outside the app.
|
|
112
|
+
* </div>
|
|
113
|
+
*
|
|
114
|
+
* ```html
|
|
115
|
+
* <!doctype html>
|
|
116
|
+
* <html>
|
|
117
|
+
* <body>
|
|
118
|
+
* <div ng-controller="WelcomeController">
|
|
119
|
+
* {{greeting}}
|
|
120
|
+
* </div>
|
|
121
|
+
*
|
|
122
|
+
* <script src="angular.js"></script>
|
|
123
|
+
* <script>
|
|
124
|
+
* let app = angular.module('demo', [])
|
|
125
|
+
* .controller('WelcomeController', function($scope) {
|
|
126
|
+
* $scope.greeting = 'Welcome!';
|
|
127
|
+
* });
|
|
128
|
+
* angular.bootstrap(document, ['demo']);
|
|
129
|
+
* </script>
|
|
130
|
+
* </body>
|
|
131
|
+
* </html>
|
|
132
|
+
* ```
|
|
133
|
+
*
|
|
134
|
+
* @param {string | Element | JQuery | Document} element DOM element which is the root of AngularJS application.
|
|
135
|
+
* @param {Array<string | Function | any[]>=} modules an array of modules to load into the application.
|
|
136
|
+
* Each item in the array should be the name of a predefined module or a (DI annotated)
|
|
137
|
+
* function that will be invoked by the injector as a `config` block.
|
|
138
|
+
* See: {@link angular.module modules}
|
|
139
|
+
* @param {angular.IAngularBootstrapConfig} config an object for defining configuration options for the application. The
|
|
140
|
+
* following keys are supported:
|
|
141
|
+
*
|
|
142
|
+
* * `strictDi` - disable automatic function annotation for the application. This is meant to
|
|
143
|
+
* assist in finding bugs which break minified code. Defaults to `false`.
|
|
144
|
+
*
|
|
145
|
+
* @returns {angular.auto.IInjectorService} Returns the newly created injector for this app.
|
|
146
|
+
*/
|
|
147
|
+
bootstrap(element, modules, config) {
|
|
148
|
+
// eslint-disable-next-line no-param-reassign
|
|
149
|
+
if (!isObject(config)) config = {};
|
|
150
|
+
const defaultConfig = {
|
|
151
|
+
strictDi: false,
|
|
152
|
+
};
|
|
153
|
+
config = extend(defaultConfig, config);
|
|
154
|
+
this.doBootstrap = function () {
|
|
155
|
+
// @ts-ignore
|
|
156
|
+
element = jqLite(element);
|
|
157
|
+
|
|
158
|
+
if (element.injector()) {
|
|
159
|
+
const tag =
|
|
160
|
+
element[0] === window.document ? "document" : startingTag(element);
|
|
161
|
+
// Encode angle brackets to prevent input from being sanitized to empty string #8683.
|
|
162
|
+
throw ngMinErr(
|
|
163
|
+
"btstrpd",
|
|
164
|
+
"App already bootstrapped with this element '{0}'",
|
|
165
|
+
tag.replace(/</, "<").replace(/>/, ">"),
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
this.bootsrappedModules = modules || [];
|
|
170
|
+
this.bootsrappedModules.unshift([
|
|
171
|
+
"$provide",
|
|
172
|
+
($provide) => {
|
|
173
|
+
$provide.value("$rootElement", element);
|
|
174
|
+
},
|
|
175
|
+
]);
|
|
176
|
+
|
|
177
|
+
if (config.debugInfoEnabled) {
|
|
178
|
+
// Pushing so that this overrides `debugInfoEnabled` setting defined in user's `modules`.
|
|
179
|
+
this.bootsrappedModules.push([
|
|
180
|
+
"$compileProvider",
|
|
181
|
+
function ($compileProvider) {
|
|
182
|
+
$compileProvider.debugInfoEnabled(true);
|
|
183
|
+
},
|
|
184
|
+
]);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
this.bootsrappedModules.unshift("ng");
|
|
188
|
+
|
|
189
|
+
const injector = createInjector(this.bootsrappedModules, config.strictDi);
|
|
190
|
+
injector.invoke([
|
|
191
|
+
"$rootScope",
|
|
192
|
+
"$rootElement",
|
|
193
|
+
"$compile",
|
|
194
|
+
"$injector",
|
|
195
|
+
function bootstrapApply(scope, el, compile, $injector) {
|
|
196
|
+
scope.$apply(() => {
|
|
197
|
+
el.data("$injector", $injector);
|
|
198
|
+
compile(el)(scope);
|
|
199
|
+
});
|
|
200
|
+
},
|
|
201
|
+
]);
|
|
202
|
+
return injector;
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
const NG_ENABLE_DEBUG_INFO = /^NG_ENABLE_DEBUG_INFO!/;
|
|
206
|
+
const NG_DEFER_BOOTSTRAP = /^NG_DEFER_BOOTSTRAP!/;
|
|
207
|
+
|
|
208
|
+
if (window && NG_ENABLE_DEBUG_INFO.test(window.name)) {
|
|
209
|
+
config.debugInfoEnabled = true;
|
|
210
|
+
window.name = window.name.replace(NG_ENABLE_DEBUG_INFO, "");
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
if (window && !NG_DEFER_BOOTSTRAP.test(window.name)) {
|
|
214
|
+
return this.doBootstrap();
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
window.name = window.name.replace(NG_DEFER_BOOTSTRAP, "");
|
|
218
|
+
this.resumeBootstrap = function (extraModules) {
|
|
219
|
+
forEach(extraModules, function (module) {
|
|
220
|
+
modules.push(module);
|
|
221
|
+
});
|
|
222
|
+
return this.doBootstrap();
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
if (isFunction(this.resumeDeferredBootstrap)) {
|
|
226
|
+
this.resumeDeferredBootstrap();
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
*
|
|
232
|
+
* @param {any[]} modules
|
|
233
|
+
* @param {boolean?} strictDi
|
|
234
|
+
* @returns {angular.auto.IInjectorService}
|
|
235
|
+
*/
|
|
236
|
+
injector(modules, strictDi) {
|
|
237
|
+
return createInjector(modules, strictDi);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
resumeBootstrap(extraModules) {
|
|
241
|
+
forEach(extraModules, (module) => {
|
|
242
|
+
this.bootsrappedModules.push(module);
|
|
243
|
+
});
|
|
244
|
+
return this.doBootstrap();
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* @ngdoc function
|
|
249
|
+
* @name angular.module
|
|
250
|
+
* @module ng
|
|
251
|
+
* @description
|
|
252
|
+
*
|
|
253
|
+
* The `angular.module` is a global place for creating, registering and retrieving AngularJS
|
|
254
|
+
* modules.
|
|
255
|
+
* All modules (AngularJS core or 3rd party) that should be available to an application must be
|
|
256
|
+
* registered using this mechanism.
|
|
257
|
+
*
|
|
258
|
+
* Passing one argument retrieves an existing {@link angular.IModule},
|
|
259
|
+
* whereas passing more than one argument creates a new {@link angular.IModule}
|
|
260
|
+
*
|
|
261
|
+
*
|
|
262
|
+
* # Module
|
|
263
|
+
*
|
|
264
|
+
* A module is a collection of services, directives, controllers, filters, and configuration information.
|
|
265
|
+
* `angular.module` is used to configure the {@link auto.$injector $injector}.
|
|
266
|
+
*
|
|
267
|
+
* ```js
|
|
268
|
+
* // Create a new module
|
|
269
|
+
* let myModule = angular.module('myModule', []);
|
|
270
|
+
*
|
|
271
|
+
* // register a new service
|
|
272
|
+
* myModule.value('appName', 'MyCoolApp');
|
|
273
|
+
*
|
|
274
|
+
* // configure existing services inside initialization blocks.
|
|
275
|
+
* myModule.config(['$locationProvider', function($locationProvider) {
|
|
276
|
+
* // Configure existing providers
|
|
277
|
+
* $locationProvider.hashPrefix('!');
|
|
278
|
+
* }]);
|
|
279
|
+
* ```
|
|
280
|
+
*
|
|
281
|
+
* Then you can create an injector and load your modules like this:
|
|
282
|
+
*
|
|
283
|
+
* ```js
|
|
284
|
+
* let injector = angular.injector(['ng', 'myModule'])
|
|
285
|
+
* ```
|
|
286
|
+
*
|
|
287
|
+
* However it's more likely that you'll just use
|
|
288
|
+
* {@link ng.directive:ngApp ngApp} or
|
|
289
|
+
* {@link angular.bootstrap} to simplify this process for you.
|
|
290
|
+
*
|
|
291
|
+
* @param {!string} name The name of the module to create or retrieve.
|
|
292
|
+
* @param {!Array.<string>=} requires If specified then new module is being created. If
|
|
293
|
+
* unspecified then the module is being retrieved for further configuration.
|
|
294
|
+
* @param {Function=} configFn Optional configuration function for the module. Same as
|
|
295
|
+
* {@link angular.IModule#config Module#config()}.
|
|
296
|
+
* @returns {angular.IModule} new module with the {@link angular.IModule} api.
|
|
297
|
+
*/
|
|
298
|
+
module(name, requires, configFn) {
|
|
299
|
+
const $injectorMinErr = minErr("$injector");
|
|
300
|
+
let info = {};
|
|
301
|
+
|
|
302
|
+
assertNotHasOwnProperty(name, "module");
|
|
303
|
+
if (requires && Object.prototype.hasOwnProperty.call(moduleCache, name)) {
|
|
304
|
+
moduleCache[name] = null;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
function ensure(obj, name, factory) {
|
|
308
|
+
// eslint-disable-next-line no-return-assign, no-param-reassign
|
|
309
|
+
return obj[name] || (obj[name] = factory());
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
return ensure(moduleCache, name, () => {
|
|
313
|
+
if (!requires) {
|
|
314
|
+
throw $injectorMinErr(
|
|
315
|
+
"nomod",
|
|
316
|
+
"Module '{0}' is not available! You either misspelled " +
|
|
317
|
+
"the module name or forgot to load it. If registering a module ensure that you " +
|
|
318
|
+
"specify the dependencies as the second argument.",
|
|
319
|
+
name,
|
|
320
|
+
);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/** @type {!Array.<Array.<*>>} */
|
|
324
|
+
const invokeQueue = [];
|
|
325
|
+
|
|
326
|
+
/** @type {!Array.<Function>} */
|
|
327
|
+
const configBlocks = [];
|
|
328
|
+
|
|
329
|
+
/** @type {!Array.<Function>} */
|
|
330
|
+
const runBlocks = [];
|
|
331
|
+
|
|
332
|
+
// eslint-disable-next-line no-use-before-define
|
|
333
|
+
const config = invokeLater("$injector", "invoke", "push", configBlocks);
|
|
334
|
+
|
|
335
|
+
/** @type {angular.IModule} */
|
|
336
|
+
const moduleInstance = {
|
|
337
|
+
// Private state
|
|
338
|
+
|
|
339
|
+
_invokeQueue: invokeQueue,
|
|
340
|
+
_configBlocks: configBlocks,
|
|
341
|
+
_runBlocks: runBlocks,
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* @ngdoc method
|
|
345
|
+
* @name angular.IModule#info
|
|
346
|
+
* @module ng
|
|
347
|
+
*
|
|
348
|
+
* @param {Object=} value Information about the module
|
|
349
|
+
* @returns {Object|angular.IModule} The current info object for this module if called as a getter,
|
|
350
|
+
* or `this` if called as a setter.
|
|
351
|
+
*
|
|
352
|
+
* @description
|
|
353
|
+
* Read and write custom information about this module.
|
|
354
|
+
* For example you could put the version of the module in here.
|
|
355
|
+
*
|
|
356
|
+
* ```js
|
|
357
|
+
* angular.module('myModule', []).info({ version: '1.0.0' });
|
|
358
|
+
* ```
|
|
359
|
+
*
|
|
360
|
+
* The version could then be read back out by accessing the module elsewhere:
|
|
361
|
+
*
|
|
362
|
+
* ```
|
|
363
|
+
* let version = angular.module('myModule').info().version;
|
|
364
|
+
* ```
|
|
365
|
+
*
|
|
366
|
+
* You can also retrieve this information during runtime via the
|
|
367
|
+
* {@link $injector#modules `$injector.modules`} property:
|
|
368
|
+
*
|
|
369
|
+
* ```js
|
|
370
|
+
* let version = $injector.modules['myModule'].info().version;
|
|
371
|
+
* ```
|
|
372
|
+
*/
|
|
373
|
+
info(value) {
|
|
374
|
+
if (isDefined(value)) {
|
|
375
|
+
if (!isObject(value))
|
|
376
|
+
throw ngMinErr(
|
|
377
|
+
"aobj",
|
|
378
|
+
"Argument '{0}' must be an object",
|
|
379
|
+
"value",
|
|
380
|
+
);
|
|
381
|
+
info = value;
|
|
382
|
+
return this;
|
|
383
|
+
}
|
|
384
|
+
return info;
|
|
385
|
+
},
|
|
386
|
+
|
|
387
|
+
/**
|
|
388
|
+
* @ngdoc property
|
|
389
|
+
* @name angular.IModule#requires
|
|
390
|
+
* @module ng
|
|
391
|
+
*
|
|
392
|
+
* @description
|
|
393
|
+
* Holds the list of modules which the injector will load before the current module is
|
|
394
|
+
* loaded.
|
|
395
|
+
*/
|
|
396
|
+
requires,
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* @ngdoc property
|
|
400
|
+
* @name angular.IModule#name
|
|
401
|
+
* @module ng
|
|
402
|
+
*
|
|
403
|
+
* @description
|
|
404
|
+
* Name of the module.
|
|
405
|
+
*/
|
|
406
|
+
name,
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* @ngdoc method
|
|
410
|
+
* @name angular.IModule#provider
|
|
411
|
+
* @module ng
|
|
412
|
+
* @param {string} name service name
|
|
413
|
+
* @param {Function} providerType Construction function for creating new instance of the
|
|
414
|
+
* service.
|
|
415
|
+
* @description
|
|
416
|
+
* See {@link auto.$provide#provider $provide.provider()}.
|
|
417
|
+
*/
|
|
418
|
+
provider: invokeLaterAndSetModuleName("$provide", "provider"),
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* @ngdoc method
|
|
422
|
+
* @name angular.IModule#factory
|
|
423
|
+
* @module ng
|
|
424
|
+
* @param {string} name service name
|
|
425
|
+
* @param {Function} providerFunction Function for creating new instance of the service.
|
|
426
|
+
* @description
|
|
427
|
+
* See {@link auto.$provide#factory $provide.factory()}.
|
|
428
|
+
*/
|
|
429
|
+
factory: invokeLaterAndSetModuleName("$provide", "factory"),
|
|
430
|
+
|
|
431
|
+
/**
|
|
432
|
+
* @ngdoc method
|
|
433
|
+
* @name angular.IModule#service
|
|
434
|
+
* @module ng
|
|
435
|
+
* @param {string} name service name
|
|
436
|
+
* @param {Function} constructor A constructor function that will be instantiated.
|
|
437
|
+
* @description
|
|
438
|
+
* See {@link auto.$provide#service $provide.service()}.
|
|
439
|
+
*/
|
|
440
|
+
service: invokeLaterAndSetModuleName("$provide", "service"),
|
|
441
|
+
|
|
442
|
+
/**
|
|
443
|
+
* @ngdoc method
|
|
444
|
+
* @name angular.IModule#value
|
|
445
|
+
* @module ng
|
|
446
|
+
* @param {string} name service name
|
|
447
|
+
* @param {*} object Service instance object.
|
|
448
|
+
* @description
|
|
449
|
+
* See {@link auto.$provide#value $provide.value()}.
|
|
450
|
+
*/
|
|
451
|
+
value: invokeLater("$provide", "value"),
|
|
452
|
+
|
|
453
|
+
/**
|
|
454
|
+
* @ngdoc method
|
|
455
|
+
* @name angular.IModule#constant
|
|
456
|
+
* @module ng
|
|
457
|
+
* @param {string} name constant name
|
|
458
|
+
* @param {*} object Constant value.
|
|
459
|
+
* @description
|
|
460
|
+
* Because the constants are fixed, they get applied before other provide methods.
|
|
461
|
+
* See {@link auto.$provide#constant $provide.constant()}.
|
|
462
|
+
*/
|
|
463
|
+
constant: invokeLater("$provide", "constant", "unshift"),
|
|
464
|
+
|
|
465
|
+
/**
|
|
466
|
+
* @ngdoc method
|
|
467
|
+
* @name angular.IModule#decorator
|
|
468
|
+
* @module ng
|
|
469
|
+
* @param {string} name The name of the service to decorate.
|
|
470
|
+
* @param {Function} decorFn This function will be invoked when the service needs to be
|
|
471
|
+
* instantiated and should return the decorated service instance.
|
|
472
|
+
* @description
|
|
473
|
+
* See {@link auto.$provide#decorator $provide.decorator()}.
|
|
474
|
+
*/
|
|
475
|
+
decorator: invokeLaterAndSetModuleName(
|
|
476
|
+
"$provide",
|
|
477
|
+
"decorator",
|
|
478
|
+
configBlocks,
|
|
479
|
+
),
|
|
480
|
+
|
|
481
|
+
/**
|
|
482
|
+
* @ngdoc method
|
|
483
|
+
* @name angular.IModule#animation
|
|
484
|
+
* @module ng
|
|
485
|
+
* @param {string} name animation name
|
|
486
|
+
* @param {Function} animationFactory Factory function for creating new instance of an
|
|
487
|
+
* animation.
|
|
488
|
+
* @description
|
|
489
|
+
*
|
|
490
|
+
* **NOTE**: animations take effect only if the **ngAnimate** module is loaded.
|
|
491
|
+
*
|
|
492
|
+
*
|
|
493
|
+
* Defines an animation hook that can be later used with
|
|
494
|
+
* {@link $animate $animate} service and directives that use this service.
|
|
495
|
+
*
|
|
496
|
+
* ```js
|
|
497
|
+
* module.animation('.animation-name', function($inject1, $inject2) {
|
|
498
|
+
* return {
|
|
499
|
+
* eventName : function(element, done) {
|
|
500
|
+
* //code to run the animation
|
|
501
|
+
* //once complete, then run done()
|
|
502
|
+
* return function cancellationFunction(element) {
|
|
503
|
+
* //code to cancel the animation
|
|
504
|
+
* }
|
|
505
|
+
* }
|
|
506
|
+
* }
|
|
507
|
+
* })
|
|
508
|
+
* ```
|
|
509
|
+
*
|
|
510
|
+
* See {@link ng.$animateProvider#register $animateProvider.register()} and
|
|
511
|
+
* {@link ngAnimate ngAnimate module} for more information.
|
|
512
|
+
*/
|
|
513
|
+
animation: invokeLaterAndSetModuleName("$animateProvider", "register"),
|
|
514
|
+
|
|
515
|
+
/**
|
|
516
|
+
* @ngdoc method
|
|
517
|
+
* @name angular.IModule#filter
|
|
518
|
+
* @module ng
|
|
519
|
+
* @param {string} name Filter name - this must be a valid AngularJS expression identifier
|
|
520
|
+
* @param {Function} filterFactory Factory function for creating new instance of filter.
|
|
521
|
+
* @description
|
|
522
|
+
* See {@link ng.$filterProvider#register $filterProvider.register()}.
|
|
523
|
+
*
|
|
524
|
+
* <div class="alert alert-warning">
|
|
525
|
+
* **Note:** Filter names must be valid AngularJS {@link expression} identifiers, such as `uppercase` or `orderBy`.
|
|
526
|
+
* Names with special characters, such as hyphens and dots, are not allowed. If you wish to namespace
|
|
527
|
+
* your filters, then you can use capitalization (`myappSubsectionFilterx`) or underscores
|
|
528
|
+
* (`myapp_subsection_filterx`).
|
|
529
|
+
* </div>
|
|
530
|
+
*/
|
|
531
|
+
filter: invokeLaterAndSetModuleName("$filterProvider", "register"),
|
|
532
|
+
|
|
533
|
+
/**
|
|
534
|
+
* @ngdoc method
|
|
535
|
+
* @name angular.IModule#controller
|
|
536
|
+
* @module ng
|
|
537
|
+
* @param {string|Object} name Controller name, or an object map of controllers where the
|
|
538
|
+
* keys are the names and the values are the constructors.
|
|
539
|
+
* @param {Function} constructor Controller constructor function.
|
|
540
|
+
* @description
|
|
541
|
+
* See {@link ng.$controllerProvider#register $controllerProvider.register()}.
|
|
542
|
+
*/
|
|
543
|
+
controller: invokeLaterAndSetModuleName(
|
|
544
|
+
"$controllerProvider",
|
|
545
|
+
"register",
|
|
546
|
+
),
|
|
547
|
+
|
|
548
|
+
/**
|
|
549
|
+
* @ngdoc method
|
|
550
|
+
* @name angular.IModule#directive
|
|
551
|
+
* @module ng
|
|
552
|
+
* @param {string|Object} name Directive name, or an object map of directives where the
|
|
553
|
+
* keys are the names and the values are the factories.
|
|
554
|
+
* @param {Function} directiveFactory Factory function for creating new instance of
|
|
555
|
+
* directives.
|
|
556
|
+
* @description
|
|
557
|
+
* See {@link ng.$compileProvider#directive $compileProvider.directive()}.
|
|
558
|
+
*/
|
|
559
|
+
directive: invokeLaterAndSetModuleName("$compileProvider", "directive"),
|
|
560
|
+
|
|
561
|
+
/**
|
|
562
|
+
* @ngdoc method
|
|
563
|
+
* @name angular.IModule#component
|
|
564
|
+
* @module ng
|
|
565
|
+
* @param {string|Object} name Name of the component in camelCase (i.e. `myComp` which will match `<my-comp>`),
|
|
566
|
+
* or an object map of components where the keys are the names and the values are the component definition objects.
|
|
567
|
+
* @param {Object} options Component definition object (a simplified
|
|
568
|
+
* {@link ng.$compile#directive-definition-object directive definition object})
|
|
569
|
+
*
|
|
570
|
+
* @description
|
|
571
|
+
* See {@link ng.$compileProvider#component $compileProvider.component()}.
|
|
572
|
+
*/
|
|
573
|
+
component: invokeLaterAndSetModuleName("$compileProvider", "component"),
|
|
574
|
+
|
|
575
|
+
/**
|
|
576
|
+
* @ngdoc method
|
|
577
|
+
* @name angular.IModule#config
|
|
578
|
+
* @module ng
|
|
579
|
+
* @param {Function} configFn Execute this function on module load. Useful for service
|
|
580
|
+
* configuration.
|
|
581
|
+
* @description
|
|
582
|
+
* Use this method to configure services by injecting their
|
|
583
|
+
* {@link angular.IModule#provider `providers`}, e.g. for adding routes to the
|
|
584
|
+
* {@link ngRoute.$routeProvider $routeProvider}.
|
|
585
|
+
*
|
|
586
|
+
* Note that you can only inject {@link angular.IModule#provider `providers`} and
|
|
587
|
+
* {@link angular.IModule#constant `constants`} into this function.
|
|
588
|
+
*
|
|
589
|
+
* For more about how to configure services, see
|
|
590
|
+
* {@link providers#provider-recipe Provider Recipe}.
|
|
591
|
+
*/
|
|
592
|
+
config,
|
|
593
|
+
|
|
594
|
+
/**
|
|
595
|
+
* @ngdoc method
|
|
596
|
+
* @name angular.IModule#run
|
|
597
|
+
* @module ng
|
|
598
|
+
* @param {Function} initializationFn Execute this function after injector creation.
|
|
599
|
+
* Useful for application initialization.
|
|
600
|
+
* @description
|
|
601
|
+
* Use this method to register work which should be performed when the injector is done
|
|
602
|
+
* loading all modules.
|
|
603
|
+
*/
|
|
604
|
+
run(block) {
|
|
605
|
+
runBlocks.push(block);
|
|
606
|
+
return this;
|
|
607
|
+
},
|
|
608
|
+
};
|
|
609
|
+
|
|
610
|
+
if (configFn) {
|
|
611
|
+
config(configFn);
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
return moduleInstance;
|
|
615
|
+
|
|
616
|
+
/**
|
|
617
|
+
* @param {string} provider
|
|
618
|
+
* @param {string} method
|
|
619
|
+
* @param {String=} insertMethod
|
|
620
|
+
* @returns {angular.IModule}
|
|
621
|
+
*/
|
|
622
|
+
function invokeLater(provider, method, insertMethod, queue) {
|
|
623
|
+
if (!queue) queue = invokeQueue;
|
|
624
|
+
return function () {
|
|
625
|
+
queue[insertMethod || "push"]([provider, method, arguments]);
|
|
626
|
+
return moduleInstance;
|
|
627
|
+
};
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
/**
|
|
631
|
+
* @param {string} provider
|
|
632
|
+
* @param {string} method
|
|
633
|
+
* @returns {angular.IModule}
|
|
634
|
+
*/
|
|
635
|
+
function invokeLaterAndSetModuleName(provider, method, queue) {
|
|
636
|
+
if (!queue) queue = invokeQueue;
|
|
637
|
+
return function (recipeName, factoryFunction) {
|
|
638
|
+
if (factoryFunction && isFunction(factoryFunction))
|
|
639
|
+
factoryFunction.$$moduleName = name;
|
|
640
|
+
queue.push([provider, method, arguments]);
|
|
641
|
+
return moduleInstance;
|
|
642
|
+
};
|
|
643
|
+
}
|
|
644
|
+
});
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
/**
|
|
648
|
+
* @module angular
|
|
649
|
+
* @function reloadWithDebugInfo
|
|
650
|
+
|
|
651
|
+
* @description
|
|
652
|
+
* Use this function to reload the current application with debug information turned on.
|
|
653
|
+
* This takes precedence over a call to `$compileProvider.debugInfoEnabled(false)`.
|
|
654
|
+
*
|
|
655
|
+
* See {@link ng.$compileProvider#debugInfoEnabled} for more.
|
|
656
|
+
*/
|
|
657
|
+
reloadWithDebugInfo() {
|
|
658
|
+
window.name = `NG_ENABLE_DEBUG_INFO!${window.name}`;
|
|
659
|
+
window.location.reload();
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
UNSAFE_restoreLegacyJqLiteXHTMLReplacement() {
|
|
663
|
+
throw new Error("Legacy function kept for TS purposes.");
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
/// //////////////////////////////////////////////
|
|
668
|
+
|
|
669
|
+
/**
|
|
670
|
+
* @ngdoc directive
|
|
671
|
+
* @name ngApp
|
|
672
|
+
*
|
|
673
|
+
* @element ANY
|
|
674
|
+
* @param {angular.IModule} ngApp an optional application
|
|
675
|
+
* {@link angular.module module} name to load.
|
|
676
|
+
* @param {boolean=} ngStrictDi if this attribute is present on the app element, the injector will be
|
|
677
|
+
* created in "strict-di" mode. This means that the application will fail to invoke functions which
|
|
678
|
+
* do not use explicit function annotation (and are thus unsuitable for minification), as described
|
|
679
|
+
* in {@link guide/di the Dependency Injection guide}, and useful debugging info will assist in
|
|
680
|
+
* tracking down the root of these bugs.
|
|
681
|
+
*
|
|
682
|
+
* @description
|
|
683
|
+
*
|
|
684
|
+
* Use this directive to **auto-bootstrap** an AngularJS application. The `ngApp` directive
|
|
685
|
+
* designates the **root element** of the application and is typically placed near the root element
|
|
686
|
+
* of the page - e.g. on the `<body>` or `<html>` tags.
|
|
687
|
+
*
|
|
688
|
+
* There are a few things to keep in mind when using `ngApp`:
|
|
689
|
+
* - only one AngularJS application can be auto-bootstrapped per HTML document. The first `ngApp`
|
|
690
|
+
* found in the document will be used to define the root element to auto-bootstrap as an
|
|
691
|
+
* application. To run multiple applications in an HTML document you must manually bootstrap them using
|
|
692
|
+
* {@link angular.bootstrap} instead.
|
|
693
|
+
* - AngularJS applications cannot be nested within each other.
|
|
694
|
+
* - Do not use a directive that uses {@link ng.$compile#transclusion transclusion} on the same element as `ngApp`.
|
|
695
|
+
* This includes directives such as {@link ng.ngIf `ngIf`}, {@link ng.ngInclude `ngInclude`} and
|
|
696
|
+
* {@link ngRoute.ngView `ngView`}.
|
|
697
|
+
* Doing this misplaces the app {@link ng.$rootElement `$rootElement`} and the app's {@link auto.$injector injector},
|
|
698
|
+
* causing animations to stop working and making the injector inaccessible from outside the app.
|
|
699
|
+
*
|
|
700
|
+
* You can specify an **AngularJS module** to be used as the root module for the application. This
|
|
701
|
+
* module will be loaded into the {@link auto.$injector} when the application is bootstrapped. It
|
|
702
|
+
* should contain the application code needed or have dependencies on other modules that will
|
|
703
|
+
* contain the code. See {@link angular.module} for more information.
|
|
704
|
+
*
|
|
705
|
+
* In the example below if the `ngApp` directive were not placed on the `html` element then the
|
|
706
|
+
* document would not be compiled, the `AppController` would not be instantiated and the `{{ a+b }}`
|
|
707
|
+
* would not be resolved to `3`.
|
|
708
|
+
*
|
|
709
|
+
* @example
|
|
710
|
+
*
|
|
711
|
+
* ### Simple Usage
|
|
712
|
+
*
|
|
713
|
+
* `ngApp` is the easiest, and most common way to bootstrap an application.
|
|
714
|
+
*
|
|
715
|
+
<example module="ngAppDemo" name="ng-app">
|
|
716
|
+
<file name="index.html">
|
|
717
|
+
<div ng-controller="ngAppDemoController">
|
|
718
|
+
I can add: {{a}} + {{b}} = {{ a+b }}
|
|
719
|
+
</div>
|
|
720
|
+
</file>
|
|
721
|
+
<file name="script.js">
|
|
722
|
+
angular.module('ngAppDemo', []).controller('ngAppDemoController', function($scope) {
|
|
723
|
+
$scope.a = 1;
|
|
724
|
+
$scope.b = 2;
|
|
725
|
+
});
|
|
726
|
+
</file>
|
|
727
|
+
</example>
|
|
728
|
+
*
|
|
729
|
+
* @example
|
|
730
|
+
*
|
|
731
|
+
* ### With `ngStrictDi`
|
|
732
|
+
*
|
|
733
|
+
* Using `ngStrictDi`, you would see something like this:
|
|
734
|
+
*
|
|
735
|
+
<example ng-app-included="true" name="strict-di">
|
|
736
|
+
<file name="index.html">
|
|
737
|
+
<div ng-app="ngAppStrictDemo" ng-strict-di>
|
|
738
|
+
<div ng-controller="GoodController1">
|
|
739
|
+
I can add: {{a}} + {{b}} = {{ a+b }}
|
|
740
|
+
|
|
741
|
+
<p>This renders because the controller does not fail to
|
|
742
|
+
instantiate, by using explicit annotation style (see
|
|
743
|
+
script.js for details)
|
|
744
|
+
</p>
|
|
745
|
+
</div>
|
|
746
|
+
|
|
747
|
+
<div ng-controller="GoodController2">
|
|
748
|
+
Name: <input ng-model="name"><br />
|
|
749
|
+
Hello, {{name}}!
|
|
750
|
+
|
|
751
|
+
<p>This renders because the controller does not fail to
|
|
752
|
+
instantiate, by using explicit annotation style
|
|
753
|
+
(see script.js for details)
|
|
754
|
+
</p>
|
|
755
|
+
</div>
|
|
756
|
+
|
|
757
|
+
<div ng-controller="BadController">
|
|
758
|
+
I can add: {{a}} + {{b}} = {{ a+b }}
|
|
759
|
+
|
|
760
|
+
<p>The controller could not be instantiated, due to relying
|
|
761
|
+
on automatic function annotations (which are disabled in
|
|
762
|
+
strict mode). As such, the content of this section is not
|
|
763
|
+
interpolated, and there should be an error in your web console.
|
|
764
|
+
</p>
|
|
765
|
+
</div>
|
|
766
|
+
</div>
|
|
767
|
+
</file>
|
|
768
|
+
<file name="script.js">
|
|
769
|
+
angular.module('ngAppStrictDemo', [])
|
|
770
|
+
// BadController will fail to instantiate, due to relying on automatic function annotation,
|
|
771
|
+
// rather than an explicit annotation
|
|
772
|
+
.controller('BadController', function($scope) {
|
|
773
|
+
$scope.a = 1;
|
|
774
|
+
$scope.b = 2;
|
|
775
|
+
})
|
|
776
|
+
// Unlike BadController, GoodController1 and GoodController2 will not fail to be instantiated,
|
|
777
|
+
// due to using explicit annotations using the array style and $inject property, respectively.
|
|
778
|
+
.controller('GoodController1', ['$scope', function($scope) {
|
|
779
|
+
$scope.a = 1;
|
|
780
|
+
$scope.b = 2;
|
|
781
|
+
}])
|
|
782
|
+
.controller('GoodController2', GoodController2);
|
|
783
|
+
function GoodController2($scope) {
|
|
784
|
+
$scope.name = 'World';
|
|
785
|
+
}
|
|
786
|
+
GoodController2.$inject = ['$scope'];
|
|
787
|
+
</file>
|
|
788
|
+
<file name="style.css">
|
|
789
|
+
div[ng-controller] {
|
|
790
|
+
margin-bottom: 1em;
|
|
791
|
+
-webkit-border-radius: 4px;
|
|
792
|
+
border-radius: 4px;
|
|
793
|
+
border: 1px solid;
|
|
794
|
+
padding: .5em;
|
|
795
|
+
}
|
|
796
|
+
div[ng-controller^=Good] {
|
|
797
|
+
border-color: #d6e9c6;
|
|
798
|
+
background-color: #dff0d8;
|
|
799
|
+
color: #3c763d;
|
|
800
|
+
}
|
|
801
|
+
div[ng-controller^=Bad] {
|
|
802
|
+
border-color: #ebccd1;
|
|
803
|
+
background-color: #f2dede;
|
|
804
|
+
color: #a94442;
|
|
805
|
+
margin-bottom: 0;
|
|
806
|
+
}
|
|
807
|
+
</file>
|
|
808
|
+
</example>
|
|
809
|
+
*/
|
|
810
|
+
export function angularInit(element) {
|
|
811
|
+
let appElement;
|
|
812
|
+
let module;
|
|
813
|
+
const config = {};
|
|
814
|
+
|
|
815
|
+
// The element `element` has priority over any other element.
|
|
816
|
+
ngAttrPrefixes.forEach((prefix) => {
|
|
817
|
+
const name = `${prefix}app`;
|
|
818
|
+
|
|
819
|
+
if (!appElement && element.hasAttribute && element.hasAttribute(name)) {
|
|
820
|
+
appElement = element;
|
|
821
|
+
module = element.getAttribute(name);
|
|
822
|
+
}
|
|
823
|
+
});
|
|
824
|
+
ngAttrPrefixes.forEach((prefix) => {
|
|
825
|
+
const name = `${prefix}app`;
|
|
826
|
+
let candidate;
|
|
827
|
+
|
|
828
|
+
if (
|
|
829
|
+
!appElement &&
|
|
830
|
+
(candidate = element.querySelector(`[${name.replace(":", "\\:")}]`))
|
|
831
|
+
) {
|
|
832
|
+
appElement = candidate;
|
|
833
|
+
module = candidate.getAttribute(name);
|
|
834
|
+
}
|
|
835
|
+
});
|
|
836
|
+
if (appElement) {
|
|
837
|
+
// Angular init is called manually, so why is this check here
|
|
838
|
+
// if (!confGlobal.isAutoBootstrapAllowed) {
|
|
839
|
+
// window.console.error(
|
|
840
|
+
// "AngularJS: disabling automatic bootstrap. <script> protocol indicates an extension, document.location.href does not match.",
|
|
841
|
+
// );
|
|
842
|
+
// return;
|
|
843
|
+
// }
|
|
844
|
+
config.strictDi = getNgAttribute(appElement, "strict-di") !== null;
|
|
845
|
+
//TODO maybe angular should be initialized here?
|
|
846
|
+
window.angular.bootstrap(appElement, module ? [module] : [], config);
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
/**
|
|
851
|
+
* @ngdoc type
|
|
852
|
+
* @name angular.IModule
|
|
853
|
+
* @module ng
|
|
854
|
+
* @description
|
|
855
|
+
*
|
|
856
|
+
* Interface for configuring AngularJS {@link angular.module modules}.
|
|
857
|
+
*/
|
|
858
|
+
export function setupModuleLoader(window) {
|
|
859
|
+
const $injectorMinErr = minErr("$injector");
|
|
860
|
+
|
|
861
|
+
function ensure(obj, name, factory) {
|
|
862
|
+
// eslint-disable-next-line no-return-assign
|
|
863
|
+
return obj[name] || (obj[name] = factory());
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
const angular = ensure(window, "angular", Object);
|
|
867
|
+
|
|
868
|
+
// We need to expose `angular.$$minErr` to modules such as `ngResource` that reference it during bootstrap
|
|
869
|
+
angular.$$minErr = angular.$$minErr || minErr;
|
|
870
|
+
|
|
871
|
+
return ensure(angular, "module", () => {
|
|
872
|
+
/** @type {Object.<string, angular.IModule>} */
|
|
873
|
+
const modules = {};
|
|
874
|
+
|
|
875
|
+
/**
|
|
876
|
+
* @ngdoc function
|
|
877
|
+
* @name angular.module
|
|
878
|
+
* @module ng
|
|
879
|
+
* @description
|
|
880
|
+
*
|
|
881
|
+
* The `angular.module` is a global place for creating, registering and retrieving AngularJS
|
|
882
|
+
* modules.
|
|
883
|
+
* All modules (AngularJS core or 3rd party) that should be available to an application must be
|
|
884
|
+
* registered using this mechanism.
|
|
885
|
+
*
|
|
886
|
+
* Passing one argument retrieves an existing {@link angular.IModule},
|
|
887
|
+
* whereas passing more than one argument creates a new {@link angular.IModule}
|
|
888
|
+
*
|
|
889
|
+
*
|
|
890
|
+
* # Module
|
|
891
|
+
*
|
|
892
|
+
* A module is a collection of services, directives, controllers, filters, and configuration information.
|
|
893
|
+
* `angular.module` is used to configure the {@link auto.$injector $injector}.
|
|
894
|
+
*
|
|
895
|
+
* ```js
|
|
896
|
+
* // Create a new module
|
|
897
|
+
* let myModule = angular.module('myModule', []);
|
|
898
|
+
*
|
|
899
|
+
* // register a new service
|
|
900
|
+
* myModule.value('appName', 'MyCoolApp');
|
|
901
|
+
*
|
|
902
|
+
* // configure existing services inside initialization blocks.
|
|
903
|
+
* myModule.config(['$locationProvider', function($locationProvider) {
|
|
904
|
+
* // Configure existing providers
|
|
905
|
+
* $locationProvider.hashPrefix('!');
|
|
906
|
+
* }]);
|
|
907
|
+
* ```
|
|
908
|
+
*
|
|
909
|
+
* Then you can create an injector and load your modules like this:
|
|
910
|
+
*
|
|
911
|
+
* ```js
|
|
912
|
+
* let injector = angular.injector(['ng', 'myModule'])
|
|
913
|
+
* ```
|
|
914
|
+
*
|
|
915
|
+
* However it's more likely that you'll just use
|
|
916
|
+
* {@link ng.directive:ngApp ngApp} or
|
|
917
|
+
* {@link angular.bootstrap} to simplify this process for you.
|
|
918
|
+
*
|
|
919
|
+
* @param {!string} name The name of the module to create or retrieve.
|
|
920
|
+
* @param {!Array.<string>=} requires If specified then new module is being created. If
|
|
921
|
+
* unspecified then the module is being retrieved for further configuration.
|
|
922
|
+
* @param {Function=} configFn Optional configuration function for the module. Same as
|
|
923
|
+
* {@link angular.IModule#config Module#config()}.
|
|
924
|
+
* @returns {angular.IModule} new module with the {@link angular.IModule} api.
|
|
925
|
+
*/
|
|
926
|
+
return function module(name, requires, configFn) {
|
|
927
|
+
let info = {};
|
|
928
|
+
|
|
929
|
+
assertNotHasOwnProperty(name, "module");
|
|
930
|
+
if (requires && Object.prototype.hasOwnProperty.call(modules, name)) {
|
|
931
|
+
modules[name] = null;
|
|
932
|
+
}
|
|
933
|
+
return ensure(modules, name, () => {
|
|
934
|
+
if (!requires) {
|
|
935
|
+
throw $injectorMinErr(
|
|
936
|
+
"nomod",
|
|
937
|
+
"Module '{0}' is not available! You either misspelled " +
|
|
938
|
+
"the module name or forgot to load it. If registering a module ensure that you " +
|
|
939
|
+
"specify the dependencies as the second argument.",
|
|
940
|
+
name,
|
|
941
|
+
);
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
/** @type {!Array.<Array.<*>>} */
|
|
945
|
+
const invokeQueue = [];
|
|
946
|
+
|
|
947
|
+
/** @type {!Array.<Function>} */
|
|
948
|
+
const configBlocks = [];
|
|
949
|
+
|
|
950
|
+
/** @type {!Array.<Function>} */
|
|
951
|
+
const runBlocks = [];
|
|
952
|
+
|
|
953
|
+
// eslint-disable-next-line no-use-before-define
|
|
954
|
+
const config = invokeLater("$injector", "invoke", "push", configBlocks);
|
|
955
|
+
|
|
956
|
+
/** @type {angular.IModule} */
|
|
957
|
+
const moduleInstance = {
|
|
958
|
+
// Private state
|
|
959
|
+
_invokeQueue: invokeQueue,
|
|
960
|
+
_configBlocks: configBlocks,
|
|
961
|
+
_runBlocks: runBlocks,
|
|
962
|
+
|
|
963
|
+
/**
|
|
964
|
+
* @ngdoc method
|
|
965
|
+
* @name angular.IModule#info
|
|
966
|
+
* @module ng
|
|
967
|
+
*
|
|
968
|
+
* @param {Object=} info Information about the module
|
|
969
|
+
* @returns {Object|Module} The current info object for this module if called as a getter,
|
|
970
|
+
* or `this` if called as a setter.
|
|
971
|
+
*
|
|
972
|
+
* @description
|
|
973
|
+
* Read and write custom information about this module.
|
|
974
|
+
* For example you could put the version of the module in here.
|
|
975
|
+
*
|
|
976
|
+
* ```js
|
|
977
|
+
* angular.module('myModule', []).info({ version: '1.0.0' });
|
|
978
|
+
* ```
|
|
979
|
+
*
|
|
980
|
+
* The version could then be read back out by accessing the module elsewhere:
|
|
981
|
+
*
|
|
982
|
+
* ```
|
|
983
|
+
* let version = angular.module('myModule').info().version;
|
|
984
|
+
* ```
|
|
985
|
+
*
|
|
986
|
+
* You can also retrieve this information during runtime via the
|
|
987
|
+
* {@link $injector#modules `$injector.modules`} property:
|
|
988
|
+
*
|
|
989
|
+
* ```js
|
|
990
|
+
* let version = $injector.modules['myModule'].info().version;
|
|
991
|
+
* ```
|
|
992
|
+
*/
|
|
993
|
+
info(value) {
|
|
994
|
+
if (isDefined(value)) {
|
|
995
|
+
if (!isObject(value))
|
|
996
|
+
throw ngMinErr(
|
|
997
|
+
"aobj",
|
|
998
|
+
"Argument '{0}' must be an object",
|
|
999
|
+
"value",
|
|
1000
|
+
);
|
|
1001
|
+
info = value;
|
|
1002
|
+
return this;
|
|
1003
|
+
}
|
|
1004
|
+
return info;
|
|
1005
|
+
},
|
|
1006
|
+
|
|
1007
|
+
/**
|
|
1008
|
+
* @ngdoc property
|
|
1009
|
+
* @name angular.IModule#requires
|
|
1010
|
+
* @module ng
|
|
1011
|
+
*
|
|
1012
|
+
* @description
|
|
1013
|
+
* Holds the list of modules which the injector will load before the current module is
|
|
1014
|
+
* loaded.
|
|
1015
|
+
*/
|
|
1016
|
+
requires,
|
|
1017
|
+
|
|
1018
|
+
/**
|
|
1019
|
+
* @ngdoc property
|
|
1020
|
+
* @name angular.IModule#name
|
|
1021
|
+
* @module ng
|
|
1022
|
+
*
|
|
1023
|
+
* @description
|
|
1024
|
+
* Name of the module.
|
|
1025
|
+
*/
|
|
1026
|
+
name,
|
|
1027
|
+
|
|
1028
|
+
/**
|
|
1029
|
+
* @ngdoc method
|
|
1030
|
+
* @name angular.IModule#provider
|
|
1031
|
+
* @module ng
|
|
1032
|
+
* @param {string} name service name
|
|
1033
|
+
* @param {Function} providerType Construction function for creating new instance of the
|
|
1034
|
+
* service.
|
|
1035
|
+
* @description
|
|
1036
|
+
* See {@link auto.$provide#provider $provide.provider()}.
|
|
1037
|
+
*/
|
|
1038
|
+
provider: invokeLaterAndSetModuleName("$provide", "provider"),
|
|
1039
|
+
|
|
1040
|
+
/**
|
|
1041
|
+
* @ngdoc method
|
|
1042
|
+
* @name angular.IModule#factory
|
|
1043
|
+
* @module ng
|
|
1044
|
+
* @param {string} name service name
|
|
1045
|
+
* @param {Function} providerFunction Function for creating new instance of the service.
|
|
1046
|
+
* @description
|
|
1047
|
+
* See {@link auto.$provide#factory $provide.factory()}.
|
|
1048
|
+
*/
|
|
1049
|
+
factory: invokeLaterAndSetModuleName("$provide", "factory"),
|
|
1050
|
+
|
|
1051
|
+
/**
|
|
1052
|
+
* @ngdoc method
|
|
1053
|
+
* @name angular.IModule#service
|
|
1054
|
+
* @module ng
|
|
1055
|
+
* @param {string} name service name
|
|
1056
|
+
* @param {Function} constructor A constructor function that will be instantiated.
|
|
1057
|
+
* @description
|
|
1058
|
+
* See {@link auto.$provide#service $provide.service()}.
|
|
1059
|
+
*/
|
|
1060
|
+
service: invokeLaterAndSetModuleName("$provide", "service"),
|
|
1061
|
+
|
|
1062
|
+
/**
|
|
1063
|
+
* @ngdoc method
|
|
1064
|
+
* @name angular.IModule#value
|
|
1065
|
+
* @module ng
|
|
1066
|
+
* @param {string} name service name
|
|
1067
|
+
* @param {*} object Service instance object.
|
|
1068
|
+
* @description
|
|
1069
|
+
* See {@link auto.$provide#value $provide.value()}.
|
|
1070
|
+
*/
|
|
1071
|
+
value: invokeLater("$provide", "value"),
|
|
1072
|
+
|
|
1073
|
+
/**
|
|
1074
|
+
* @ngdoc method
|
|
1075
|
+
* @name angular.IModule#constant
|
|
1076
|
+
* @module ng
|
|
1077
|
+
* @param {string} name constant name
|
|
1078
|
+
* @param {*} object Constant value.
|
|
1079
|
+
* @description
|
|
1080
|
+
* Because the constants are fixed, they get applied before other provide methods.
|
|
1081
|
+
* See {@link auto.$provide#constant $provide.constant()}.
|
|
1082
|
+
*/
|
|
1083
|
+
constant: invokeLater("$provide", "constant", "unshift"),
|
|
1084
|
+
|
|
1085
|
+
/**
|
|
1086
|
+
* @ngdoc method
|
|
1087
|
+
* @name angular.IModule#decorator
|
|
1088
|
+
* @module ng
|
|
1089
|
+
* @param {string} name The name of the service to decorate.
|
|
1090
|
+
* @param {Function} decorFn This function will be invoked when the service needs to be
|
|
1091
|
+
* instantiated and should return the decorated service instance.
|
|
1092
|
+
* @description
|
|
1093
|
+
* See {@link auto.$provide#decorator $provide.decorator()}.
|
|
1094
|
+
*/
|
|
1095
|
+
decorator: invokeLaterAndSetModuleName(
|
|
1096
|
+
"$provide",
|
|
1097
|
+
"decorator",
|
|
1098
|
+
configBlocks,
|
|
1099
|
+
),
|
|
1100
|
+
|
|
1101
|
+
/**
|
|
1102
|
+
* @ngdoc method
|
|
1103
|
+
* @name angular.IModule#animation
|
|
1104
|
+
* @module ng
|
|
1105
|
+
* @param {string} name animation name
|
|
1106
|
+
* @param {Function} animationFactory Factory function for creating new instance of an
|
|
1107
|
+
* animation.
|
|
1108
|
+
* @description
|
|
1109
|
+
*
|
|
1110
|
+
* **NOTE**: animations take effect only if the **ngAnimate** module is loaded.
|
|
1111
|
+
*
|
|
1112
|
+
*
|
|
1113
|
+
* Defines an animation hook that can be later used with
|
|
1114
|
+
* {@link $animate $animate} service and directives that use this service.
|
|
1115
|
+
*
|
|
1116
|
+
* ```js
|
|
1117
|
+
* module.animation('.animation-name', function($inject1, $inject2) {
|
|
1118
|
+
* return {
|
|
1119
|
+
* eventName : function(element, done) {
|
|
1120
|
+
* //code to run the animation
|
|
1121
|
+
* //once complete, then run done()
|
|
1122
|
+
* return function cancellationFunction(element) {
|
|
1123
|
+
* //code to cancel the animation
|
|
1124
|
+
* }
|
|
1125
|
+
* }
|
|
1126
|
+
* }
|
|
1127
|
+
* })
|
|
1128
|
+
* ```
|
|
1129
|
+
*
|
|
1130
|
+
* See {@link ng.$animateProvider#register $animateProvider.register()} and
|
|
1131
|
+
* {@link ngAnimate ngAnimate module} for more information.
|
|
1132
|
+
*/
|
|
1133
|
+
animation: invokeLaterAndSetModuleName(
|
|
1134
|
+
"$animateProvider",
|
|
1135
|
+
"register",
|
|
1136
|
+
),
|
|
1137
|
+
|
|
1138
|
+
/**
|
|
1139
|
+
* @ngdoc method
|
|
1140
|
+
* @name angular.IModule#filter
|
|
1141
|
+
* @module ng
|
|
1142
|
+
* @param {string} name Filter name - this must be a valid AngularJS expression identifier
|
|
1143
|
+
* @param {Function} filterFactory Factory function for creating new instance of filter.
|
|
1144
|
+
* @description
|
|
1145
|
+
* See {@link ng.$filterProvider#register $filterProvider.register()}.
|
|
1146
|
+
*
|
|
1147
|
+
* <div class="alert alert-warning">
|
|
1148
|
+
* **Note:** Filter names must be valid AngularJS {@link expression} identifiers, such as `uppercase` or `orderBy`.
|
|
1149
|
+
* Names with special characters, such as hyphens and dots, are not allowed. If you wish to namespace
|
|
1150
|
+
* your filters, then you can use capitalization (`myappSubsectionFilterx`) or underscores
|
|
1151
|
+
* (`myapp_subsection_filterx`).
|
|
1152
|
+
* </div>
|
|
1153
|
+
*/
|
|
1154
|
+
filter: invokeLaterAndSetModuleName("$filterProvider", "register"),
|
|
1155
|
+
|
|
1156
|
+
/**
|
|
1157
|
+
* @ngdoc method
|
|
1158
|
+
* @name angular.IModule#controller
|
|
1159
|
+
* @module ng
|
|
1160
|
+
* @param {string|Object} name Controller name, or an object map of controllers where the
|
|
1161
|
+
* keys are the names and the values are the constructors.
|
|
1162
|
+
* @param {Function} constructor Controller constructor function.
|
|
1163
|
+
* @description
|
|
1164
|
+
* See {@link ng.$controllerProvider#register $controllerProvider.register()}.
|
|
1165
|
+
*/
|
|
1166
|
+
controller: invokeLaterAndSetModuleName(
|
|
1167
|
+
"$controllerProvider",
|
|
1168
|
+
"register",
|
|
1169
|
+
),
|
|
1170
|
+
|
|
1171
|
+
/**
|
|
1172
|
+
* @ngdoc method
|
|
1173
|
+
* @name angular.IModule#directive
|
|
1174
|
+
* @module ng
|
|
1175
|
+
* @param {string|Object} name Directive name, or an object map of directives where the
|
|
1176
|
+
* keys are the names and the values are the factories.
|
|
1177
|
+
* @param {Function} directiveFactory Factory function for creating new instance of
|
|
1178
|
+
* directives.
|
|
1179
|
+
* @description
|
|
1180
|
+
* See {@link ng.$compileProvider#directive $compileProvider.directive()}.
|
|
1181
|
+
*/
|
|
1182
|
+
directive: invokeLaterAndSetModuleName(
|
|
1183
|
+
"$compileProvider",
|
|
1184
|
+
"directive",
|
|
1185
|
+
),
|
|
1186
|
+
|
|
1187
|
+
/**
|
|
1188
|
+
* @ngdoc method
|
|
1189
|
+
* @name angular.IModule#component
|
|
1190
|
+
* @module ng
|
|
1191
|
+
* @param {string|Object} name Name of the component in camelCase (i.e. `myComp` which will match `<my-comp>`),
|
|
1192
|
+
* or an object map of components where the keys are the names and the values are the component definition objects.
|
|
1193
|
+
* @param {Object} options Component definition object (a simplified
|
|
1194
|
+
* {@link ng.$compile#directive-definition-object directive definition object})
|
|
1195
|
+
*
|
|
1196
|
+
* @description
|
|
1197
|
+
* See {@link ng.$compileProvider#component $compileProvider.component()}.
|
|
1198
|
+
*/
|
|
1199
|
+
component: invokeLaterAndSetModuleName(
|
|
1200
|
+
"$compileProvider",
|
|
1201
|
+
"component",
|
|
1202
|
+
),
|
|
1203
|
+
|
|
1204
|
+
/**
|
|
1205
|
+
* @ngdoc method
|
|
1206
|
+
* @name angular.IModule#config
|
|
1207
|
+
* @module ng
|
|
1208
|
+
* @param {Function} configFn Execute this function on module load. Useful for service
|
|
1209
|
+
* configuration.
|
|
1210
|
+
* @description
|
|
1211
|
+
* Use this method to configure services by injecting their
|
|
1212
|
+
* {@link angular.IModule#provider `providers`}, e.g. for adding routes to the
|
|
1213
|
+
* {@link ngRoute.$routeProvider $routeProvider}.
|
|
1214
|
+
*
|
|
1215
|
+
* Note that you can only inject {@link angular.IModule#provider `providers`} and
|
|
1216
|
+
* {@link angular.IModule#constant `constants`} into this function.
|
|
1217
|
+
*
|
|
1218
|
+
* For more about how to configure services, see
|
|
1219
|
+
* {@link providers#provider-recipe Provider Recipe}.
|
|
1220
|
+
*/
|
|
1221
|
+
config,
|
|
1222
|
+
|
|
1223
|
+
/**
|
|
1224
|
+
* @ngdoc method
|
|
1225
|
+
* @name angular.IModule#run
|
|
1226
|
+
* @module ng
|
|
1227
|
+
* @param {Function} initializationFn Execute this function after injector creation.
|
|
1228
|
+
* Useful for application initialization.
|
|
1229
|
+
* @description
|
|
1230
|
+
* Use this method to register work which should be performed when the injector is done
|
|
1231
|
+
* loading all modules.
|
|
1232
|
+
*/
|
|
1233
|
+
run(block) {
|
|
1234
|
+
runBlocks.push(block);
|
|
1235
|
+
return this;
|
|
1236
|
+
},
|
|
1237
|
+
};
|
|
1238
|
+
|
|
1239
|
+
if (configFn) {
|
|
1240
|
+
config(configFn);
|
|
1241
|
+
}
|
|
1242
|
+
|
|
1243
|
+
return moduleInstance;
|
|
1244
|
+
|
|
1245
|
+
/**
|
|
1246
|
+
* @param {string} provider
|
|
1247
|
+
* @param {string} method
|
|
1248
|
+
* @param {String=} insertMethod
|
|
1249
|
+
* @returns {angular.IModule}
|
|
1250
|
+
*/
|
|
1251
|
+
function invokeLater(provider, method, insertMethod, queue) {
|
|
1252
|
+
if (!queue) queue = invokeQueue;
|
|
1253
|
+
return function () {
|
|
1254
|
+
queue[insertMethod || "push"]([provider, method, arguments]);
|
|
1255
|
+
return moduleInstance;
|
|
1256
|
+
};
|
|
1257
|
+
}
|
|
1258
|
+
|
|
1259
|
+
/**
|
|
1260
|
+
* @param {string} provider
|
|
1261
|
+
* @param {string} method
|
|
1262
|
+
* @returns {angular.IModule}
|
|
1263
|
+
*/
|
|
1264
|
+
function invokeLaterAndSetModuleName(provider, method, queue) {
|
|
1265
|
+
if (!queue) queue = invokeQueue;
|
|
1266
|
+
return function (recipeName, factoryFunction) {
|
|
1267
|
+
if (factoryFunction && isFunction(factoryFunction))
|
|
1268
|
+
factoryFunction.$$moduleName = name;
|
|
1269
|
+
queue.push([provider, method, arguments]);
|
|
1270
|
+
return moduleInstance;
|
|
1271
|
+
};
|
|
1272
|
+
}
|
|
1273
|
+
});
|
|
1274
|
+
};
|
|
1275
|
+
});
|
|
1276
|
+
}
|
|
1277
|
+
|
|
1278
|
+
/**
|
|
1279
|
+
* @ngdoc function
|
|
1280
|
+
* @name angular.errorHandlingConfig
|
|
1281
|
+
* @module ng
|
|
1282
|
+
* @kind function
|
|
1283
|
+
*
|
|
1284
|
+
* @description
|
|
1285
|
+
* Configure several aspects of error handling in AngularJS if used as a setter or return the
|
|
1286
|
+
* current configuration if used as a getter. The following options are supported:
|
|
1287
|
+
*
|
|
1288
|
+
* - **objectMaxDepth**: The maximum depth to which objects are traversed when stringified for error messages.
|
|
1289
|
+
*
|
|
1290
|
+
* Omitted or undefined options will leave the corresponding configuration values unchanged.
|
|
1291
|
+
*
|
|
1292
|
+
* @param {Object=} config - The configuration object. May only contain the options that need to be
|
|
1293
|
+
* updated. Supported keys:
|
|
1294
|
+
*
|
|
1295
|
+
* * `objectMaxDepth` **{Number}** - The max depth for stringifying objects. Setting to a
|
|
1296
|
+
* non-positive or non-numeric value, removes the max depth limit.
|
|
1297
|
+
* Default: 5
|
|
1298
|
+
*
|
|
1299
|
+
* * `urlErrorParamsEnabled` **{Boolean}** - Specifies whether the generated error url will
|
|
1300
|
+
* contain the parameters of the thrown error. Disabling the parameters can be useful if the
|
|
1301
|
+
* generated error url is very long.
|
|
1302
|
+
*
|
|
1303
|
+
* Default: true. When used without argument, it returns the current value.
|
|
1304
|
+
*/
|
|
1305
|
+
export function errorHandlingConfig(config) {
|
|
1306
|
+
if (isObject(config)) {
|
|
1307
|
+
if (isDefined(config.objectMaxDepth)) {
|
|
1308
|
+
minErrConfig.objectMaxDepth = isValidObjectMaxDepth(config.objectMaxDepth)
|
|
1309
|
+
? config.objectMaxDepth
|
|
1310
|
+
: NaN;
|
|
1311
|
+
}
|
|
1312
|
+
if (
|
|
1313
|
+
isDefined(config.urlErrorParamsEnabled) &&
|
|
1314
|
+
isBoolean(config.urlErrorParamsEnabled)
|
|
1315
|
+
) {
|
|
1316
|
+
minErrConfig.urlErrorParamsEnabled = config.urlErrorParamsEnabled;
|
|
1317
|
+
}
|
|
1318
|
+
}
|
|
1319
|
+
return minErrConfig;
|
|
1320
|
+
}
|