2016-07-18 06:50:31 -04:00
|
|
|
/**
|
|
|
|
* @license
|
|
|
|
* Copyright Google Inc. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
|
|
* found in the LICENSE file at https://angular.io/license
|
|
|
|
*/
|
|
|
|
|
2018-05-09 11:35:25 -04:00
|
|
|
import {APP_INITIALIZER, ApplicationInitStatus} from './application_init';
|
2018-04-26 17:08:13 -04:00
|
|
|
import {ApplicationRef} from './application_ref';
|
2016-07-18 06:50:31 -04:00
|
|
|
import {APP_ID_RANDOM_PROVIDER} from './application_tokens';
|
|
|
|
import {IterableDiffers, KeyValueDiffers, defaultIterableDiffers, defaultKeyValueDiffers} from './change_detection/change_detection';
|
2018-05-09 19:49:39 -04:00
|
|
|
import {Console} from './console';
|
|
|
|
import {InjectionToken, Injector, StaticProvider} from './di';
|
2017-01-05 12:24:37 -05:00
|
|
|
import {Inject, Optional, SkipSelf} from './di/metadata';
|
2018-05-09 19:49:39 -04:00
|
|
|
import {ErrorHandler} from './error_handler';
|
2016-08-12 19:52:55 -04:00
|
|
|
import {LOCALE_ID} from './i18n/tokens';
|
2018-05-09 19:49:39 -04:00
|
|
|
import {ComponentFactoryResolver} from './linker';
|
2018-04-26 17:08:13 -04:00
|
|
|
import {Compiler} from './linker/compiler';
|
2016-07-18 06:50:31 -04:00
|
|
|
import {NgModule} from './metadata';
|
2018-05-09 19:49:39 -04:00
|
|
|
import {NgZone} from './zone';
|
2016-07-18 06:50:31 -04:00
|
|
|
|
|
|
|
export function _iterableDiffersFactory() {
|
|
|
|
return defaultIterableDiffers;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function _keyValueDiffersFactory() {
|
|
|
|
return defaultKeyValueDiffers;
|
|
|
|
}
|
|
|
|
|
2017-01-05 12:24:37 -05:00
|
|
|
export function _localeFactory(locale?: string): string {
|
|
|
|
return locale || 'en-US';
|
|
|
|
}
|
|
|
|
|
2018-08-22 11:52:19 -04:00
|
|
|
/**
|
|
|
|
* A built-in [dependency injection token](guide/glossary#di-token)
|
|
|
|
* that is used to configure the root injector for bootstrapping.
|
|
|
|
*/
|
2018-05-09 19:49:39 -04:00
|
|
|
export const APPLICATION_MODULE_PROVIDERS: StaticProvider[] = [
|
|
|
|
{
|
|
|
|
provide: ApplicationRef,
|
|
|
|
useClass: ApplicationRef,
|
|
|
|
deps:
|
|
|
|
[NgZone, Console, Injector, ErrorHandler, ComponentFactoryResolver, ApplicationInitStatus]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
provide: ApplicationInitStatus,
|
|
|
|
useClass: ApplicationInitStatus,
|
|
|
|
deps: [[new Optional(), APP_INITIALIZER]]
|
|
|
|
},
|
|
|
|
{provide: Compiler, useClass: Compiler, deps: []},
|
|
|
|
APP_ID_RANDOM_PROVIDER,
|
|
|
|
{provide: IterableDiffers, useFactory: _iterableDiffersFactory, deps: []},
|
|
|
|
{provide: KeyValueDiffers, useFactory: _keyValueDiffersFactory, deps: []},
|
|
|
|
{
|
|
|
|
provide: LOCALE_ID,
|
|
|
|
useFactory: _localeFactory,
|
|
|
|
deps: [[new Inject(LOCALE_ID), new Optional(), new SkipSelf()]]
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
2016-07-18 06:50:31 -04:00
|
|
|
/**
|
2018-08-22 11:52:19 -04:00
|
|
|
* Configures the root injector for an app with
|
|
|
|
* providers of `@angular/core` dependencies that `ApplicationRef` needs
|
|
|
|
* to bootstrap components.
|
|
|
|
*
|
|
|
|
* Re-exported by `BrowserModule`, which is included automatically in the root
|
|
|
|
* `AppModule` when you create a new app with the CLI `new` command.
|
2018-04-26 17:08:13 -04:00
|
|
|
*
|
2016-07-18 06:50:31 -04:00
|
|
|
* @experimental
|
|
|
|
*/
|
2018-05-09 19:49:39 -04:00
|
|
|
@NgModule({providers: APPLICATION_MODULE_PROVIDERS})
|
2016-07-18 06:50:31 -04:00
|
|
|
export class ApplicationModule {
|
2018-04-26 17:08:13 -04:00
|
|
|
// Inject ApplicationRef to make it eager...
|
|
|
|
constructor(appRef: ApplicationRef) {}
|
2016-07-18 06:50:31 -04:00
|
|
|
}
|