* Bootstrap an AngularJS application from this NgModule * @param element the element on which to bootstrap the AngularJS application * @param [modules] the AngularJS modules to bootstrap for this application * @param [config] optional extra AngularJS bootstrap configuration * @return The
(
element: Element,
modules: string[] = [],
config?: any /*angular.IAngularBootstrapConfig*/,
)
| 181 | * [angular.bootstrap()](https://docs.angularjs.org/api/ng/function/angular.bootstrap). |
| 182 | */ |
| 183 | bootstrap( |
| 184 | element: Element, |
| 185 | modules: string[] = [], |
| 186 | config?: any /*angular.IAngularBootstrapConfig*/, |
| 187 | ): any /*ReturnType<typeof angular.bootstrap>*/ { |
| 188 | const INIT_MODULE_NAME = ɵconstants.UPGRADE_MODULE_NAME + '.init'; |
| 189 | |
| 190 | // Create an ng1 module to bootstrap |
| 191 | ɵangular1 |
| 192 | .module_(INIT_MODULE_NAME, []) |
| 193 | |
| 194 | .constant(ɵconstants.UPGRADE_APP_TYPE_KEY, ɵutil.UpgradeAppType.Static) |
| 195 | |
| 196 | .value(ɵconstants.INJECTOR_KEY, this.injector) |
| 197 | |
| 198 | .factory(ɵconstants.LAZY_MODULE_REF, [ |
| 199 | ɵconstants.INJECTOR_KEY, |
| 200 | (injector: Injector) => ({injector}) as ɵutil.LazyModuleRef, |
| 201 | ]) |
| 202 | |
| 203 | .config([ |
| 204 | ɵconstants.$PROVIDE, |
| 205 | ɵconstants.$INJECTOR, |
| 206 | ($provide: ɵangular1.IProvideService, $injector: ɵangular1.IInjectorService) => { |
| 207 | if ($injector.has(ɵconstants.$$TESTABILITY)) { |
| 208 | $provide.decorator(ɵconstants.$$TESTABILITY, [ |
| 209 | ɵconstants.$DELEGATE, |
| 210 | (testabilityDelegate: ɵangular1.ITestabilityService) => { |
| 211 | const originalWhenStable: Function = testabilityDelegate.whenStable; |
| 212 | const injector = this.injector; |
| 213 | // Cannot use arrow function below because we need the context |
| 214 | const newWhenStable = function (callback: Function) { |
| 215 | originalWhenStable.call(testabilityDelegate, function () { |
| 216 | const ng2Testability: Testability = injector.get(Testability); |
| 217 | if (ng2Testability.isStable()) { |
| 218 | callback(); |
| 219 | } else { |
| 220 | ng2Testability.whenStable(newWhenStable.bind(testabilityDelegate, callback)); |
| 221 | } |
| 222 | }); |
| 223 | }; |
| 224 | |
| 225 | testabilityDelegate.whenStable = newWhenStable; |
| 226 | return testabilityDelegate; |
| 227 | }, |
| 228 | ]); |
| 229 | } |
| 230 | |
| 231 | if ($injector.has(ɵconstants.$INTERVAL)) { |
| 232 | $provide.decorator(ɵconstants.$INTERVAL, [ |
| 233 | ɵconstants.$DELEGATE, |
| 234 | (intervalDelegate: ɵangular1.IIntervalService) => { |
| 235 | // Wrap the $interval service so that setInterval is called outside NgZone, |
| 236 | // but the callback is still invoked within it. This is so that $interval |
| 237 | // won't block stability, which preserves the behavior from AngularJS. |
| 238 | let wrappedInterval = ( |
| 239 | fn: Function, |
| 240 | delay: number, |
no test coverage detected