refactor(application): rename Binding into Provider
while creating the server version I noticed bindings are still mentioned Closes #4951
This commit is contained in:
@ -49,7 +49,7 @@ import {Compiler_} from "./linker/compiler";
|
||||
* These are providers that should be singletons shared among all Angular applications
|
||||
* running on the page.
|
||||
*/
|
||||
export function platformBindings(): Array<Type | Provider | any[]> {
|
||||
export function platformProviders(): Array<Type | Provider | any[]> {
|
||||
return [provide(Reflector, {useValue: reflector}), TestabilityRegistry];
|
||||
}
|
||||
|
||||
@ -62,7 +62,7 @@ function _componentProviders(appComponentType: Type): Array<Type | Provider | an
|
||||
provide(APP_COMPONENT_REF_PROMISE,
|
||||
{
|
||||
useFactory: (dynamicComponentLoader, injector: Injector) => {
|
||||
// TODO(rado): investigate whether to support bindings on root component.
|
||||
// TODO(rado): investigate whether to support providers on root component.
|
||||
return dynamicComponentLoader.loadAsRoot(appComponentType, null, injector)
|
||||
.then((componentRef) => {
|
||||
if (isPresent(componentRef.location.nativeElement)) {
|
||||
@ -87,7 +87,7 @@ function _componentProviders(appComponentType: Type): Array<Type | Provider | an
|
||||
* Construct a default set of providers which should be included in any Angular
|
||||
* application, regardless of whether it runs on the UI thread or in a web worker.
|
||||
*/
|
||||
export function applicationCommonBindings(): Array<Type | Provider | any[]> {
|
||||
export function applicationCommonProviders(): Array<Type | Provider | any[]> {
|
||||
return [
|
||||
provide(Compiler, {useClass: Compiler_}),
|
||||
APP_ID_RANDOM_PROVIDER,
|
||||
@ -121,10 +121,10 @@ export function createNgZone(): NgZone {
|
||||
|
||||
var _platform: PlatformRef;
|
||||
|
||||
export function platformCommon(bindings?: Array<Type | Provider | any[]>, initializer?: () => void):
|
||||
PlatformRef {
|
||||
export function platformCommon(providers?: Array<Type | Provider | any[]>,
|
||||
initializer?: () => void): PlatformRef {
|
||||
if (isPresent(_platform)) {
|
||||
if (isBlank(bindings)) {
|
||||
if (isBlank(providers)) {
|
||||
return _platform;
|
||||
}
|
||||
throw "platform() can only be called once per page";
|
||||
@ -134,10 +134,10 @@ export function platformCommon(bindings?: Array<Type | Provider | any[]>, initia
|
||||
initializer();
|
||||
}
|
||||
|
||||
if (isBlank(bindings)) {
|
||||
bindings = platformBindings();
|
||||
if (isBlank(providers)) {
|
||||
providers = platformProviders();
|
||||
}
|
||||
_platform = new PlatformRef_(Injector.resolveAndCreate(bindings), () => { _platform = null; });
|
||||
_platform = new PlatformRef_(Injector.resolveAndCreate(providers), () => { _platform = null; });
|
||||
return _platform;
|
||||
}
|
||||
|
||||
@ -170,7 +170,7 @@ export abstract class PlatformRef {
|
||||
* renderer, and other framework components. An application hosts one or more
|
||||
* root components, which can be initialized via `ApplicationRef.bootstrap()`.
|
||||
*
|
||||
*##Application Bindings
|
||||
*##Application Providers
|
||||
*
|
||||
* Angular applications require numerous providers to be properly instantiated.
|
||||
* When using `application()` to create a new app on the page, these providers
|
||||
@ -179,17 +179,17 @@ export abstract class PlatformRef {
|
||||
*
|
||||
* ### Example
|
||||
* ```
|
||||
* var myAppBindings = [MyAppService];
|
||||
* var myAppProviders = [MyAppService];
|
||||
*
|
||||
* platform()
|
||||
* .application([applicationCommonBindings(), applicationDomBindings(), myAppBindings])
|
||||
* .application([applicationCommonProviders(), applicationDomProviders(), myAppProviders])
|
||||
* .bootstrap(MyTopLevelComponent);
|
||||
* ```
|
||||
*##See Also
|
||||
*
|
||||
* See the {@link bootstrap} documentation for more details.
|
||||
*/
|
||||
abstract application(bindings: Array<Type | Provider | any[]>): ApplicationRef;
|
||||
abstract application(providers: Array<Type | Provider | any[]>): ApplicationRef;
|
||||
|
||||
/**
|
||||
* Instantiate a new Angular application on the page, using providers which
|
||||
@ -223,8 +223,8 @@ export class PlatformRef_ extends PlatformRef {
|
||||
|
||||
get injector(): Injector { return this._injector; }
|
||||
|
||||
application(bindings: Array<Type | Provider | any[]>): ApplicationRef {
|
||||
var app = this._initApp(createNgZone(), bindings);
|
||||
application(providers: Array<Type | Provider | any[]>): ApplicationRef {
|
||||
var app = this._initApp(createNgZone(), providers);
|
||||
return app;
|
||||
}
|
||||
|
||||
@ -233,8 +233,8 @@ export class PlatformRef_ extends PlatformRef {
|
||||
var zone = createNgZone();
|
||||
var completer = PromiseWrapper.completer();
|
||||
zone.run(() => {
|
||||
PromiseWrapper.then(bindingFn(zone), (bindings: Array<Type | Provider | any[]>) => {
|
||||
completer.resolve(this._initApp(zone, bindings));
|
||||
PromiseWrapper.then(bindingFn(zone), (providers: Array<Type | Provider | any[]>) => {
|
||||
completer.resolve(this._initApp(zone, providers));
|
||||
});
|
||||
});
|
||||
return completer.promise;
|
||||
@ -301,20 +301,20 @@ export abstract class ApplicationRef {
|
||||
* specified application component onto DOM elements identified by the [componentType]'s
|
||||
* selector and kicks off automatic change detection to finish initializing the component.
|
||||
*
|
||||
*##Optional Bindings
|
||||
*##Optional Providers
|
||||
*
|
||||
* Bindings for the given component can optionally be overridden via the `providers`
|
||||
* Providers for the given component can optionally be overridden via the `providers`
|
||||
* parameter. These providers will only apply for the root component being added and any
|
||||
* child components under it.
|
||||
*
|
||||
* ### Example
|
||||
* ```
|
||||
* var app = platform.application([applicationCommonBindings(), applicationDomBindings()];
|
||||
* var app = platform.application([applicationCommonProviders(), applicationDomProviders()];
|
||||
* app.bootstrap(FirstRootComponent);
|
||||
* app.bootstrap(SecondRootComponent, [provide(OverrideBinding, {useClass: OverriddenBinding})]);
|
||||
* ```
|
||||
*/
|
||||
abstract bootstrap(componentType: Type, bindings?: Array<Type | Provider | any[]>):
|
||||
abstract bootstrap(componentType: Type, providers?: Array<Type | Provider | any[]>):
|
||||
Promise<ComponentRef>;
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user