@@ -18,11 +18,11 @@ export 'package:angular2/src/core/linker/dynamic_component_loader.dart' show Com
|
||||
///
|
||||
/// See [commonBootstrap] for detailed documentation.
|
||||
Future<ComponentRef> bootstrap(Type appComponentType,
|
||||
[List componentInjectableBindings]) {
|
||||
[List componentInjectableProviders]) {
|
||||
reflector.reflectionCapabilities = new ReflectionCapabilities();
|
||||
var bindings = [compilerBindings()];
|
||||
if (componentInjectableBindings != null) {
|
||||
bindings.add(componentInjectableBindings);
|
||||
var providers = [compilerProviders()];
|
||||
if (componentInjectableProviders != null) {
|
||||
providers.add(componentInjectableProviders);
|
||||
}
|
||||
return commonBootstrap(appComponentType, bindings);
|
||||
return commonBootstrap(appComponentType, providers);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// Public API for Application
|
||||
import {Binding} from './di';
|
||||
import {Provider} from './di';
|
||||
import {Type, isPresent} from 'angular2/src/core/facade/lang';
|
||||
import {Promise} from 'angular2/src/core/facade/async';
|
||||
import {compilerBindings} from 'angular2/src/core/compiler/compiler';
|
||||
import {compilerProviders} from 'angular2/src/core/compiler/compiler';
|
||||
import {commonBootstrap} from './application_common';
|
||||
import {ComponentRef} from './linker/dynamic_component_loader';
|
||||
|
||||
@@ -19,9 +19,9 @@ export {
|
||||
|
||||
/// See [commonBootstrap] for detailed documentation.
|
||||
export function bootstrap(appComponentType: /*Type*/ any,
|
||||
appBindings: Array<Type | Binding | any[]> = null):
|
||||
appBindings: Array<Type | Provider | any[]> = null):
|
||||
Promise<ComponentRef> {
|
||||
var bindings = [compilerBindings()];
|
||||
var bindings = [compilerProviders()];
|
||||
if (isPresent(appBindings)) {
|
||||
bindings.push(appBindings);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {FORM_BINDINGS} from 'angular2/src/core/forms';
|
||||
import {bind, Binding, Injector, OpaqueToken} from 'angular2/src/core/di';
|
||||
import {FORM_PROVIDERS} from 'angular2/src/core/forms';
|
||||
import {provide, Provider, Injector, OpaqueToken} from 'angular2/src/core/di';
|
||||
import {
|
||||
NumberWrapper,
|
||||
Type,
|
||||
@@ -34,37 +34,36 @@ import {
|
||||
SharedStylesHost,
|
||||
DomSharedStylesHost
|
||||
} from 'angular2/src/core/render/dom/shared_styles_host';
|
||||
import {EXCEPTION_BINDING} from './platform_bindings';
|
||||
import {EXCEPTION_PROVIDER} from './platform_bindings';
|
||||
import {AnimationBuilder} from 'angular2/src/animate/animation_builder';
|
||||
import {BrowserDetails} from 'angular2/src/animate/browser_details';
|
||||
import {wtfInit} from './profile/wtf_init';
|
||||
import {platformCommon, PlatformRef, applicationCommonBindings} from './application_ref';
|
||||
|
||||
/**
|
||||
* A default set of bindings which apply only to an Angular application running on
|
||||
* A default set of providers which apply only to an Angular application running on
|
||||
* the UI thread.
|
||||
*/
|
||||
export function applicationDomBindings(): Array<Type | Binding | any[]> {
|
||||
export function applicationDomBindings(): Array<Type | Provider | any[]> {
|
||||
if (isBlank(DOM)) {
|
||||
throw "Must set a root DOM adapter first.";
|
||||
}
|
||||
return [
|
||||
bind(DOCUMENT)
|
||||
.toValue(DOM.defaultDoc()),
|
||||
provide(DOCUMENT, {asValue: DOM.defaultDoc()}),
|
||||
EventManager,
|
||||
new Binding(EVENT_MANAGER_PLUGINS, {toClass: DomEventsPlugin, multi: true}),
|
||||
new Binding(EVENT_MANAGER_PLUGINS, {toClass: KeyEventsPlugin, multi: true}),
|
||||
new Binding(EVENT_MANAGER_PLUGINS, {toClass: HammerGesturesPlugin, multi: true}),
|
||||
bind(DomRenderer).toClass(DomRenderer_),
|
||||
bind(Renderer).toAlias(DomRenderer),
|
||||
new Provider(EVENT_MANAGER_PLUGINS, {toClass: DomEventsPlugin, multi: true}),
|
||||
new Provider(EVENT_MANAGER_PLUGINS, {toClass: KeyEventsPlugin, multi: true}),
|
||||
new Provider(EVENT_MANAGER_PLUGINS, {toClass: HammerGesturesPlugin, multi: true}),
|
||||
provide(DomRenderer, {asClass: DomRenderer_}),
|
||||
provide(Renderer, {asAlias: DomRenderer}),
|
||||
DomSharedStylesHost,
|
||||
bind(SharedStylesHost).toAlias(DomSharedStylesHost),
|
||||
EXCEPTION_BINDING,
|
||||
bind(XHR).toValue(new XHRImpl()),
|
||||
provide(SharedStylesHost, {asAlias: DomSharedStylesHost}),
|
||||
EXCEPTION_PROVIDER,
|
||||
provide(XHR, {asValue: new XHRImpl()}),
|
||||
Testability,
|
||||
BrowserDetails,
|
||||
AnimationBuilder,
|
||||
FORM_BINDINGS
|
||||
FORM_PROVIDERS
|
||||
];
|
||||
}
|
||||
|
||||
@@ -73,25 +72,25 @@ export function applicationDomBindings(): Array<Type | Binding | any[]> {
|
||||
*
|
||||
* See {@link PlatformRef} for details on the Angular platform.
|
||||
*
|
||||
* # Without specified bindings
|
||||
* # Without specified providers
|
||||
*
|
||||
* If no bindings are specified, `platform`'s behavior depends on whether an existing
|
||||
* If no providers are specified, `platform`'s behavior depends on whether an existing
|
||||
* platform exists:
|
||||
*
|
||||
* If no platform exists, a new one will be created with the default {@link platformBindings}.
|
||||
*
|
||||
* If a platform already exists, it will be returned (regardless of what bindings it
|
||||
* If a platform already exists, it will be returned (regardless of what providers it
|
||||
* was created with). This is a convenience feature, allowing for multiple applications
|
||||
* to be loaded into the same platform without awareness of each other.
|
||||
*
|
||||
* # With specified bindings
|
||||
* # With specified providers
|
||||
*
|
||||
* It is also possible to specify bindings to be made in the new platform. These bindings
|
||||
* It is also possible to specify providers to be made in the new platform. These providers
|
||||
* will be shared between all applications on the page. For example, an abstraction for
|
||||
* the browser cookie jar should be bound at the platform level, because there is only one
|
||||
* cookie jar regardless of how many applications on the age will be accessing it.
|
||||
*
|
||||
* If bindings are specified directly, `platform` will create the Angular platform with
|
||||
* If providers are specified directly, `platform` will create the Angular platform with
|
||||
* them if a platform did not exist already. If it did exist, however, an error will be
|
||||
* thrown.
|
||||
*
|
||||
@@ -101,7 +100,7 @@ export function applicationDomBindings(): Array<Type | Binding | any[]> {
|
||||
* DOM access. Web-worker applications should call `platform` from
|
||||
* `src/web_workers/worker/application_common` instead.
|
||||
*/
|
||||
export function platform(bindings?: Array<Type | Binding | any[]>): PlatformRef {
|
||||
export function platform(bindings?: Array<Type | Provider | any[]>): PlatformRef {
|
||||
return platformCommon(bindings, () => {
|
||||
BrowserDomAdapter.makeCurrent();
|
||||
wtfInit();
|
||||
@@ -129,10 +128,10 @@ export function platform(bindings?: Array<Type | Binding | any[]>): PlatformRef
|
||||
* ```
|
||||
*
|
||||
* An application is bootstrapped inside an existing browser DOM, typically `index.html`.
|
||||
* Unlike Angular 1, Angular 2 does not compile/process bindings in `index.html`. This is
|
||||
* Unlike Angular 1, Angular 2 does not compile/process providers in `index.html`. This is
|
||||
* mainly for security reasons, as well as architectural changes in Angular 2. This means
|
||||
* that `index.html` can safely be processed using server-side technologies such as
|
||||
* bindings. Bindings can thus use double-curly `{{ syntax }}` without collision from
|
||||
* providers. Bindings can thus use double-curly `{{ syntax }}` without collision from
|
||||
* Angular 2 component double-curly `{{ syntax }}`.
|
||||
*
|
||||
* We can use this script code:
|
||||
@@ -170,7 +169,7 @@ export function platform(bindings?: Array<Type | Binding | any[]>): PlatformRef
|
||||
* 4. It creates a shadow DOM on the selected component's host element and loads the
|
||||
* template into it.
|
||||
* 5. It instantiates the specified component.
|
||||
* 6. Finally, Angular performs change detection to apply the initial data bindings for the
|
||||
* 6. Finally, Angular performs change detection to apply the initial data providers for the
|
||||
* application.
|
||||
*
|
||||
*
|
||||
@@ -214,7 +213,7 @@ export function platform(bindings?: Array<Type | Binding | any[]>): PlatformRef
|
||||
* # API
|
||||
* - `appComponentType`: The root component which should act as the application. This is
|
||||
* a reference to a `Type` which is annotated with `@Component(...)`.
|
||||
* - `componentInjectableBindings`: An additional set of bindings that can be added to the
|
||||
* - `componentInjectableBindings`: An additional set of providers that can be added to the
|
||||
* app injector to override default injection behavior.
|
||||
* - `errorReporter`: `function(exception:any, stackTrace:string)` a default error reporter
|
||||
* for unhandled exceptions.
|
||||
@@ -222,7 +221,7 @@ export function platform(bindings?: Array<Type | Binding | any[]>): PlatformRef
|
||||
* Returns a `Promise` of {@link ComponentRef}.
|
||||
*/
|
||||
export function commonBootstrap(appComponentType: /*Type*/ any,
|
||||
appBindings: Array<Type | Binding | any[]> = null):
|
||||
appBindings: Array<Type | Provider | any[]> = null):
|
||||
Promise<ComponentRef> {
|
||||
var p = platform();
|
||||
var bindings = [applicationCommonBindings(), applicationDomBindings()];
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import {NgZone} from 'angular2/src/core/zone/ng_zone';
|
||||
import {Type, isBlank, isPresent, assertionsEnabled} from 'angular2/src/core/facade/lang';
|
||||
import {bind, Binding, Injector, OpaqueToken} from 'angular2/src/core/di';
|
||||
import {provide, Provider, Injector, OpaqueToken} from 'angular2/src/core/di';
|
||||
import {
|
||||
APP_COMPONENT_REF_PROMISE,
|
||||
APP_COMPONENT,
|
||||
APP_ID_RANDOM_BINDING
|
||||
APP_ID_RANDOM_PROVIDER
|
||||
} from './application_tokens';
|
||||
import {Promise, PromiseWrapper, PromiseCompleter} from 'angular2/src/core/facade/async';
|
||||
import {ListWrapper} from 'angular2/src/core/facade/collection';
|
||||
@@ -44,67 +44,71 @@ import {AppViewManager_} from "./linker/view_manager";
|
||||
import {Compiler_} from "./linker/compiler";
|
||||
|
||||
/**
|
||||
* Constructs the set of bindings meant for use at the platform level.
|
||||
* Constructs the set of providers meant for use at the platform level.
|
||||
*
|
||||
* These are bindings that should be singletons shared among all Angular applications
|
||||
* These are providers that should be singletons shared among all Angular applications
|
||||
* running on the page.
|
||||
*/
|
||||
export function platformBindings(): Array<Type | Binding | any[]> {
|
||||
return [bind(Reflector).toValue(reflector), TestabilityRegistry];
|
||||
export function platformBindings(): Array<Type | Provider | any[]> {
|
||||
return [provide(Reflector, {asValue: reflector}), TestabilityRegistry];
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct bindings specific to an individual root component.
|
||||
* Construct providers specific to an individual root component.
|
||||
*/
|
||||
function _componentBindings(appComponentType: Type): Array<Type | Binding | any[]> {
|
||||
function _componentProviders(appComponentType: Type): Array<Type | Provider | any[]> {
|
||||
return [
|
||||
bind(APP_COMPONENT)
|
||||
.toValue(appComponentType),
|
||||
bind(APP_COMPONENT_REF_PROMISE)
|
||||
.toFactory(
|
||||
(dynamicComponentLoader, injector: Injector) => {
|
||||
// TODO(rado): investigate whether to support bindings on root component.
|
||||
return dynamicComponentLoader.loadAsRoot(appComponentType, null, injector)
|
||||
.then((componentRef) => {
|
||||
if (isPresent(componentRef.location.nativeElement)) {
|
||||
injector.get(TestabilityRegistry)
|
||||
.registerApplication(componentRef.location.nativeElement,
|
||||
injector.get(Testability));
|
||||
}
|
||||
return componentRef;
|
||||
});
|
||||
},
|
||||
[DynamicComponentLoader, Injector]),
|
||||
|
||||
bind(appComponentType)
|
||||
.toFactory((p: Promise<any>) => p.then(ref => ref.instance), [APP_COMPONENT_REF_PROMISE]),
|
||||
provide(APP_COMPONENT, {asValue: appComponentType}),
|
||||
provide(APP_COMPONENT_REF_PROMISE,
|
||||
{
|
||||
asFactory: (dynamicComponentLoader, injector: Injector) => {
|
||||
// TODO(rado): investigate whether to support bindings on root component.
|
||||
return dynamicComponentLoader.loadAsRoot(appComponentType, null, injector)
|
||||
.then((componentRef) => {
|
||||
if (isPresent(componentRef.location.nativeElement)) {
|
||||
injector.get(TestabilityRegistry)
|
||||
.registerApplication(componentRef.location.nativeElement,
|
||||
injector.get(Testability));
|
||||
}
|
||||
return componentRef;
|
||||
});
|
||||
},
|
||||
deps: [DynamicComponentLoader, Injector]
|
||||
}),
|
||||
provide(appComponentType,
|
||||
{
|
||||
asFactory: (p: Promise<any>) => p.then(ref => ref.instance),
|
||||
deps: [APP_COMPONENT_REF_PROMISE]
|
||||
}),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a default set of bindings which should be included in any Angular
|
||||
* 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 | Binding | any[]> {
|
||||
export function applicationCommonBindings(): Array<Type | Provider | any[]> {
|
||||
return [
|
||||
bind(Compiler)
|
||||
.toClass(Compiler_),
|
||||
APP_ID_RANDOM_BINDING,
|
||||
provide(Compiler, {asClass: Compiler_}),
|
||||
APP_ID_RANDOM_PROVIDER,
|
||||
AppViewPool,
|
||||
bind(APP_VIEW_POOL_CAPACITY).toValue(10000),
|
||||
bind(AppViewManager).toClass(AppViewManager_),
|
||||
provide(APP_VIEW_POOL_CAPACITY, {asValue: 10000}),
|
||||
provide(AppViewManager, {asClass: AppViewManager_}),
|
||||
AppViewManagerUtils,
|
||||
AppViewListener,
|
||||
ProtoViewFactory,
|
||||
ViewResolver,
|
||||
DEFAULT_PIPES,
|
||||
bind(IterableDiffers).toValue(defaultIterableDiffers),
|
||||
bind(KeyValueDiffers).toValue(defaultKeyValueDiffers),
|
||||
provide(IterableDiffers, {asValue: defaultIterableDiffers}),
|
||||
provide(KeyValueDiffers, {asValue: defaultKeyValueDiffers}),
|
||||
DirectiveResolver,
|
||||
PipeResolver,
|
||||
bind(DynamicComponentLoader).toClass(DynamicComponentLoader_),
|
||||
bind(LifeCycle).toFactory((exceptionHandler) => new LifeCycle_(null, assertionsEnabled()),
|
||||
[ExceptionHandler]),
|
||||
provide(DynamicComponentLoader, {asClass: DynamicComponentLoader_}),
|
||||
provide(LifeCycle,
|
||||
{
|
||||
asFactory: (exceptionHandler) => new LifeCycle_(null, assertionsEnabled()),
|
||||
deps: [ExceptionHandler]
|
||||
})
|
||||
];
|
||||
}
|
||||
|
||||
@@ -117,7 +121,7 @@ export function createNgZone(): NgZone {
|
||||
|
||||
var _platform: PlatformRef;
|
||||
|
||||
export function platformCommon(bindings?: Array<Type | Binding | any[]>, initializer?: () => void):
|
||||
export function platformCommon(bindings?: Array<Type | Provider | any[]>, initializer?: () => void):
|
||||
PlatformRef {
|
||||
if (isPresent(_platform)) {
|
||||
if (isBlank(bindings)) {
|
||||
@@ -148,7 +152,7 @@ export function platformCommon(bindings?: Array<Type | Binding | any[]>, initial
|
||||
export abstract class PlatformRef {
|
||||
/**
|
||||
* Retrieve the platform {@link Injector}, which is the parent injector for
|
||||
* every Angular application on the page and provides singleton bindings.
|
||||
* every Angular application on the page and provides singleton providers.
|
||||
*/
|
||||
get injector(): Injector { return unimplemented(); };
|
||||
|
||||
@@ -163,10 +167,10 @@ export abstract class PlatformRef {
|
||||
*
|
||||
* # Application Bindings
|
||||
*
|
||||
* Angular applications require numerous bindings to be properly instantiated.
|
||||
* When using `application()` to create a new app on the page, these bindings
|
||||
* Angular applications require numerous providers to be properly instantiated.
|
||||
* When using `application()` to create a new app on the page, these providers
|
||||
* must be provided. Fortunately, there are helper functions to configure
|
||||
* typical bindings, as shown in the example below.
|
||||
* typical providers, as shown in the example below.
|
||||
*
|
||||
* # Example
|
||||
* ```
|
||||
@@ -180,21 +184,21 @@ export abstract class PlatformRef {
|
||||
*
|
||||
* See the {@link bootstrap} documentation for more details.
|
||||
*/
|
||||
abstract application(bindings: Array<Type | Binding | any[]>): ApplicationRef;
|
||||
abstract application(bindings: Array<Type | Provider | any[]>): ApplicationRef;
|
||||
|
||||
/**
|
||||
* Instantiate a new Angular application on the page, using bindings which
|
||||
* Instantiate a new Angular application on the page, using providers which
|
||||
* are only available asynchronously. One such use case is to initialize an
|
||||
* application running in a web worker.
|
||||
*
|
||||
* # Usage
|
||||
*
|
||||
* `bindingFn` is a function that will be called in the new application's zone.
|
||||
* It should return a {@link Promise} to a list of bindings to be used for the
|
||||
* It should return a {@link Promise} to a list of providers to be used for the
|
||||
* new application. Once this promise resolves, the application will be
|
||||
* constructed in the same manner as a normal `application()`.
|
||||
*/
|
||||
abstract asyncApplication(bindingFn: (zone: NgZone) => Promise<Array<Type | Binding | any[]>>):
|
||||
abstract asyncApplication(bindingFn: (zone: NgZone) => Promise<Array<Type | Provider | any[]>>):
|
||||
Promise<ApplicationRef>;
|
||||
|
||||
/**
|
||||
@@ -211,33 +215,33 @@ export class PlatformRef_ extends PlatformRef {
|
||||
|
||||
get injector(): Injector { return this._injector; }
|
||||
|
||||
application(bindings: Array<Type | Binding | any[]>): ApplicationRef {
|
||||
application(bindings: Array<Type | Provider | any[]>): ApplicationRef {
|
||||
var app = this._initApp(createNgZone(), bindings);
|
||||
return app;
|
||||
}
|
||||
|
||||
asyncApplication(bindingFn: (zone: NgZone) =>
|
||||
Promise<Array<Type | Binding | any[]>>): Promise<ApplicationRef> {
|
||||
Promise<Array<Type | Provider | any[]>>): Promise<ApplicationRef> {
|
||||
var zone = createNgZone();
|
||||
var completer = PromiseWrapper.completer();
|
||||
zone.run(() => {
|
||||
PromiseWrapper.then(bindingFn(zone), (bindings: Array<Type | Binding | any[]>) => {
|
||||
PromiseWrapper.then(bindingFn(zone), (bindings: Array<Type | Provider | any[]>) => {
|
||||
completer.resolve(this._initApp(zone, bindings));
|
||||
});
|
||||
});
|
||||
return completer.promise;
|
||||
}
|
||||
|
||||
private _initApp(zone: NgZone, bindings: Array<Type | Binding | any[]>): ApplicationRef {
|
||||
private _initApp(zone: NgZone, providers: Array<Type | Provider | any[]>): ApplicationRef {
|
||||
var injector: Injector;
|
||||
var app: ApplicationRef;
|
||||
zone.run(() => {
|
||||
bindings.push(bind(NgZone).toValue(zone));
|
||||
bindings.push(bind(ApplicationRef).toFactory((): ApplicationRef => app, []));
|
||||
providers.push(provide(NgZone, {asValue: zone}));
|
||||
providers.push(provide(ApplicationRef, {asFactory: (): ApplicationRef => app, deps: []}));
|
||||
|
||||
var exceptionHandler;
|
||||
try {
|
||||
injector = this.injector.resolveAndCreateChild(bindings);
|
||||
injector = this.injector.resolveAndCreateChild(providers);
|
||||
exceptionHandler = injector.get(ExceptionHandler);
|
||||
zone.overrideOnErrorHandler((e, s) => exceptionHandler.call(e, s));
|
||||
} catch (e) {
|
||||
@@ -285,18 +289,18 @@ export abstract class ApplicationRef {
|
||||
*
|
||||
* # Optional Bindings
|
||||
*
|
||||
* Bindings for the given component can optionally be overridden via the `bindings`
|
||||
* parameter. These bindings will only apply for the root component being added and any
|
||||
* Bindings 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()];
|
||||
* app.bootstrap(FirstRootComponent);
|
||||
* app.bootstrap(SecondRootComponent, [bind(OverrideBinding).toClass(OverriddenBinding)]);
|
||||
* app.bootstrap(SecondRootComponent, [provide(OverrideBinding, {asClass: OverriddenBinding})]);
|
||||
* ```
|
||||
*/
|
||||
abstract bootstrap(componentType: Type, bindings?: Array<Type | Binding | any[]>):
|
||||
abstract bootstrap(componentType: Type, bindings?: Array<Type | Provider | any[]>):
|
||||
Promise<ComponentRef>;
|
||||
|
||||
/**
|
||||
@@ -333,17 +337,18 @@ export class ApplicationRef_ extends ApplicationRef {
|
||||
this._bootstrapListeners.push(listener);
|
||||
}
|
||||
|
||||
bootstrap(componentType: Type, bindings?: Array<Type | Binding | any[]>): Promise<ComponentRef> {
|
||||
bootstrap(componentType: Type,
|
||||
providers?: Array<Type | Provider | any[]>): Promise<ComponentRef> {
|
||||
var completer = PromiseWrapper.completer();
|
||||
this._zone.run(() => {
|
||||
var componentBindings = _componentBindings(componentType);
|
||||
if (isPresent(bindings)) {
|
||||
componentBindings.push(bindings);
|
||||
var componentProviders = _componentProviders(componentType);
|
||||
if (isPresent(providers)) {
|
||||
componentProviders.push(providers);
|
||||
}
|
||||
var exceptionHandler = this._injector.get(ExceptionHandler);
|
||||
this._rootComponentTypes.push(componentType);
|
||||
try {
|
||||
var injector: Injector = this._injector.resolveAndCreateChild(componentBindings);
|
||||
var injector: Injector = this._injector.resolveAndCreateChild(componentProviders);
|
||||
var compRefToken: Promise<ComponentRef> = injector.get(APP_COMPONENT_REF_PROMISE);
|
||||
var tick = (componentRef) => {
|
||||
var appChangeDetector = internalView(componentRef.hostView).changeDetector;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {OpaqueToken, Binding} from 'angular2/src/core/di';
|
||||
import {OpaqueToken, Provider} from 'angular2/src/core/di';
|
||||
import {CONST_EXPR, Math, StringWrapper} from 'angular2/src/core/facade/lang';
|
||||
|
||||
/**
|
||||
@@ -31,20 +31,20 @@ export const APP_COMPONENT: OpaqueToken = CONST_EXPR(new OpaqueToken('AppCompone
|
||||
* {@link ViewEncapsulation#Emulated} is being used.
|
||||
*
|
||||
* If you need to avoid randomly generated value to be used as an application id, you can provide
|
||||
* a custom value via a DI binding <!-- TODO: provider --> configuring the root {@link Injector}
|
||||
* a custom value via a DI provider <!-- TODO: provider --> configuring the root {@link Injector}
|
||||
* using this token.
|
||||
*/
|
||||
export const APP_ID: OpaqueToken = CONST_EXPR(new OpaqueToken('AppId'));
|
||||
|
||||
function _appIdRandomBindingFactory() {
|
||||
function _appIdRandomProviderFactory() {
|
||||
return `${_randomChar()}${_randomChar()}${_randomChar()}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Bindings that will generate a random APP_ID_TOKEN.
|
||||
*/
|
||||
export const APP_ID_RANDOM_BINDING: Binding =
|
||||
CONST_EXPR(new Binding(APP_ID, {toFactory: _appIdRandomBindingFactory, deps: []}));
|
||||
export const APP_ID_RANDOM_PROVIDER: Provider =
|
||||
CONST_EXPR(new Provider(APP_ID, {toFactory: _appIdRandomProviderFactory, deps: []}));
|
||||
|
||||
function _randomChar(): string {
|
||||
return StringWrapper.fromCharCode(97 + Math.floor(Math.random() * 25));
|
||||
|
||||
@@ -85,7 +85,7 @@ export abstract class ChangeDetectorRef {
|
||||
* }
|
||||
*
|
||||
* @Component({
|
||||
* selector: 'app', bindings: [DataProvider]
|
||||
* selector: 'app', providers: [DataProvider]
|
||||
* })
|
||||
* @View({
|
||||
* template: `
|
||||
@@ -166,7 +166,7 @@ export abstract class ChangeDetectorRef {
|
||||
*
|
||||
* @Component({
|
||||
* selector: 'app',
|
||||
* bindings: [DataProvider]
|
||||
* providers: [DataProvider]
|
||||
* })
|
||||
* @View({
|
||||
* template: `
|
||||
|
||||
@@ -2,7 +2,7 @@ import {isBlank, isPresent, CONST} from 'angular2/src/core/facade/lang';
|
||||
import {BaseException} from 'angular2/src/core/facade/exceptions';
|
||||
import {ListWrapper} from 'angular2/src/core/facade/collection';
|
||||
import {ChangeDetectorRef} from '../change_detector_ref';
|
||||
import {Binding, SkipSelfMetadata, OptionalMetadata, Injectable} from 'angular2/src/core/di';
|
||||
import {Provider, SkipSelfMetadata, OptionalMetadata, Injectable} from 'angular2/src/core/di';
|
||||
|
||||
export interface IterableDiffer {
|
||||
diff(object: Object): any;
|
||||
@@ -36,7 +36,7 @@ export class IterableDiffers {
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes an array of {@link IterableDifferFactory} and returns a binding used to extend the
|
||||
* Takes an array of {@link IterableDifferFactory} and returns a provider used to extend the
|
||||
* inherited {@link IterableDiffers} instance with the provided factories and return a new
|
||||
* {@link IterableDiffers} instance.
|
||||
*
|
||||
@@ -48,14 +48,14 @@ export class IterableDiffers {
|
||||
*
|
||||
* ```
|
||||
* @Component({
|
||||
* viewBindings: [
|
||||
* viewProviders: [
|
||||
* IterableDiffers.extend([new ImmutableListDiffer()])
|
||||
* ]
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
static extend(factories: IterableDifferFactory[]): Binding {
|
||||
return new Binding(IterableDiffers, {
|
||||
static extend(factories: IterableDifferFactory[]): Provider {
|
||||
return new Provider(IterableDiffers, {
|
||||
toFactory: (parent: IterableDiffers) => {
|
||||
if (isBlank(parent)) {
|
||||
// Typically would occur when calling IterableDiffers.extend inside of dependencies passed
|
||||
|
||||
@@ -2,7 +2,7 @@ import {isBlank, isPresent, CONST} from 'angular2/src/core/facade/lang';
|
||||
import {BaseException} from 'angular2/src/core/facade/exceptions';
|
||||
import {ListWrapper} from 'angular2/src/core/facade/collection';
|
||||
import {ChangeDetectorRef} from '../change_detector_ref';
|
||||
import {Binding, SkipSelfMetadata, OptionalMetadata, Injectable} from 'angular2/src/core/di';
|
||||
import {Provider, SkipSelfMetadata, OptionalMetadata, Injectable} from 'angular2/src/core/di';
|
||||
|
||||
export interface KeyValueDiffer {
|
||||
diff(object: Object);
|
||||
@@ -36,7 +36,7 @@ export class KeyValueDiffers {
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes an array of {@link KeyValueDifferFactory} and returns a binding used to extend the
|
||||
* Takes an array of {@link KeyValueDifferFactory} and returns a provider used to extend the
|
||||
* inherited {@link KeyValueDiffers} instance with the provided factories and return a new
|
||||
* {@link KeyValueDiffers} instance.
|
||||
*
|
||||
@@ -48,14 +48,14 @@ export class KeyValueDiffers {
|
||||
*
|
||||
* ```
|
||||
* @Component({
|
||||
* viewBindings: [
|
||||
* viewProviders: [
|
||||
* KeyValueDiffers.extend([new ImmutableMapDiffer()])
|
||||
* ]
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
static extend(factories: KeyValueDifferFactory[]): Binding {
|
||||
return new Binding(KeyValueDiffers, {
|
||||
static extend(factories: KeyValueDifferFactory[]): Provider {
|
||||
return new Provider(KeyValueDiffers, {
|
||||
toFactory: (parent: KeyValueDiffers) => {
|
||||
if (isBlank(parent)) {
|
||||
// Typically would occur when calling KeyValueDiffers.extend inside of dependencies passed
|
||||
|
||||
@@ -8,7 +8,7 @@ export {
|
||||
export {SourceModule, SourceWithImports} from './source_module';
|
||||
|
||||
import {assertionsEnabled, Type} from 'angular2/src/core/facade/lang';
|
||||
import {bind, Binding} from 'angular2/src/core/di';
|
||||
import {provide, Provider} from 'angular2/src/core/di';
|
||||
import {TemplateParser} from 'angular2/src/core/compiler/template_parser';
|
||||
import {HtmlParser} from 'angular2/src/core/compiler/html_parser';
|
||||
import {TemplateNormalizer} from 'angular2/src/core/compiler/template_normalizer';
|
||||
@@ -29,7 +29,7 @@ import {AppRootUrl} from 'angular2/src/core/compiler/app_root_url';
|
||||
import {AnchorBasedAppRootUrl} from 'angular2/src/core/compiler/anchor_based_app_root_url';
|
||||
import {Parser, Lexer} from 'angular2/src/core/change_detection/change_detection';
|
||||
|
||||
export function compilerBindings(): Array<Type | Binding | any[]> {
|
||||
export function compilerProviders(): Array<Type | Provider | any[]> {
|
||||
return [
|
||||
Lexer,
|
||||
Parser,
|
||||
@@ -40,16 +40,18 @@ export function compilerBindings(): Array<Type | Binding | any[]> {
|
||||
StyleCompiler,
|
||||
CommandCompiler,
|
||||
ChangeDetectionCompiler,
|
||||
bind(ChangeDetectorGenConfig)
|
||||
.toValue(
|
||||
new ChangeDetectorGenConfig(assertionsEnabled(), assertionsEnabled(), false, true)),
|
||||
provide(ChangeDetectorGenConfig,
|
||||
{
|
||||
asValue:
|
||||
new ChangeDetectorGenConfig(assertionsEnabled(), assertionsEnabled(), false, true)
|
||||
}),
|
||||
TemplateCompiler,
|
||||
bind(RuntimeCompiler).toClass(RuntimeCompiler_),
|
||||
bind(Compiler).toAlias(RuntimeCompiler),
|
||||
provide(RuntimeCompiler, {asClass: RuntimeCompiler_}),
|
||||
provide(Compiler, {asAlias: RuntimeCompiler}),
|
||||
DomElementSchemaRegistry,
|
||||
bind(ElementSchemaRegistry).toAlias(DomElementSchemaRegistry),
|
||||
provide(ElementSchemaRegistry, {asAlias: DomElementSchemaRegistry}),
|
||||
AnchorBasedAppRootUrl,
|
||||
bind(AppRootUrl).toAlias(AnchorBasedAppRootUrl),
|
||||
provide(AppRootUrl, {asAlias: AnchorBasedAppRootUrl}),
|
||||
UrlResolver
|
||||
];
|
||||
}
|
||||
|
||||
@@ -1,2 +1,6 @@
|
||||
export {DebugElement, asNativeElements, By, Scope, inspectElement} from './debug/debug_element';
|
||||
export {inspectNativeElement, ELEMENT_PROBE_BINDINGS} from './debug/debug_element_view_listener';
|
||||
export {
|
||||
inspectNativeElement,
|
||||
ELEMENT_PROBE_PROVIDERS,
|
||||
ELEMENT_PROBE_BINDINGS
|
||||
} from './debug/debug_element_view_listener';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {CONST_EXPR, isPresent, NumberWrapper, StringWrapper} from 'angular2/src/core/facade/lang';
|
||||
import {MapWrapper, Map, ListWrapper} from 'angular2/src/core/facade/collection';
|
||||
import {Injectable, bind, Binding} from 'angular2/src/core/di';
|
||||
import {Injectable, provide, Provider} from 'angular2/src/core/di';
|
||||
import {AppViewListener} from 'angular2/src/core/linker/view_listener';
|
||||
import {AppView} from 'angular2/src/core/linker/view';
|
||||
import {DOM} from 'angular2/src/core/dom/dom_adapter';
|
||||
@@ -67,7 +67,9 @@ export class DebugElementViewListener implements AppViewListener {
|
||||
}
|
||||
}
|
||||
|
||||
export const ELEMENT_PROBE_BINDINGS: any[] = CONST_EXPR([
|
||||
export const ELEMENT_PROBE_PROVIDERS: any[] = CONST_EXPR([
|
||||
DebugElementViewListener,
|
||||
CONST_EXPR(new Binding(AppViewListener, {toAlias: DebugElementViewListener})),
|
||||
CONST_EXPR(new Provider(AppViewListener, {toAlias: DebugElementViewListener})),
|
||||
]);
|
||||
|
||||
export const ELEMENT_PROBE_BINDINGS = ELEMENT_PROBE_PROVIDERS;
|
||||
@@ -21,19 +21,23 @@ export {forwardRef, resolveForwardRef, ForwardRefFn} from './di/forward_ref';
|
||||
export {Injector} from './di/injector';
|
||||
export {
|
||||
Binding,
|
||||
BindingBuilder,
|
||||
ProviderBuilder,
|
||||
ResolvedBinding,
|
||||
ResolvedFactory,
|
||||
Dependency,
|
||||
bind
|
||||
} from './di/binding';
|
||||
bind,
|
||||
|
||||
Provider,
|
||||
ResolvedProvider,
|
||||
provide
|
||||
} from './di/provider';
|
||||
export {Key, TypeLiteral} from './di/key';
|
||||
export {
|
||||
NoBindingError,
|
||||
AbstractBindingError,
|
||||
NoProviderError,
|
||||
AbstractProviderError,
|
||||
CyclicDependencyError,
|
||||
InstantiationError,
|
||||
InvalidBindingError,
|
||||
InvalidProviderError,
|
||||
NoAnnotationError,
|
||||
OutOfBoundsError
|
||||
} from './di/exceptions';
|
||||
|
||||
@@ -29,9 +29,9 @@ function constructResolvingPath(keys: any[]): string {
|
||||
|
||||
|
||||
/**
|
||||
* Base class for all errors arising from misconfigured bindings.
|
||||
* Base class for all errors arising from misconfigured providers.
|
||||
*/
|
||||
export class AbstractBindingError extends BaseException {
|
||||
export class AbstractProviderError extends BaseException {
|
||||
/** @internal */
|
||||
message: string;
|
||||
|
||||
@@ -63,7 +63,7 @@ export class AbstractBindingError extends BaseException {
|
||||
|
||||
/**
|
||||
* Thrown when trying to retrieve a dependency by `Key` from {@link Injector}, but the
|
||||
* {@link Injector} does not have a {@link Binding} for {@link Key}.
|
||||
* {@link Injector} does not have a {@link Provider} for {@link Key}.
|
||||
*
|
||||
* ### Example ([live demo](http://plnkr.co/edit/vq8D3FRB9aGbnWJqtEPE?p=preview))
|
||||
*
|
||||
@@ -75,7 +75,7 @@ export class AbstractBindingError extends BaseException {
|
||||
* expect(() => Injector.resolveAndCreate([A])).toThrowError();
|
||||
* ```
|
||||
*/
|
||||
export class NoBindingError extends AbstractBindingError {
|
||||
export class NoProviderError extends AbstractProviderError {
|
||||
constructor(injector: Injector, key: Key) {
|
||||
super(injector, key, function(keys: any[]) {
|
||||
var first = stringify(ListWrapper.first(keys).token);
|
||||
@@ -91,8 +91,8 @@ export class NoBindingError extends AbstractBindingError {
|
||||
*
|
||||
* ```typescript
|
||||
* var injector = Injector.resolveAndCreate([
|
||||
* bind("one").toFactory((two) => "two", [[new Inject("two")]]),
|
||||
* bind("two").toFactory((one) => "one", [[new Inject("one")]])
|
||||
* provide("one", {asFactory: (two) => "two", deps: [[new Inject("two")]]}),
|
||||
* provide("two", {asFactory: (one) => "one", deps: [[new Inject("one")]]})
|
||||
* ]);
|
||||
*
|
||||
* expect(() => injector.get("one")).toThrowError();
|
||||
@@ -100,7 +100,7 @@ export class NoBindingError extends AbstractBindingError {
|
||||
*
|
||||
* Retrieving `A` or `B` throws a `CyclicDependencyError` as the graph above cannot be constructed.
|
||||
*/
|
||||
export class CyclicDependencyError extends AbstractBindingError {
|
||||
export class CyclicDependencyError extends AbstractProviderError {
|
||||
constructor(injector: Injector, key: Key) {
|
||||
super(injector, key, function(keys: any[]) {
|
||||
return `Cannot instantiate cyclic dependency!${constructResolvingPath(keys)}`;
|
||||
@@ -163,7 +163,7 @@ export class InstantiationError extends WrappedException {
|
||||
}
|
||||
|
||||
/**
|
||||
* Thrown when an object other then {@link Binding} (or `Type`) is passed to {@link Injector}
|
||||
* Thrown when an object other then {@link Provider} (or `Type`) is passed to {@link Injector}
|
||||
* creation.
|
||||
*
|
||||
* ### Example ([live demo](http://plnkr.co/edit/YatCFbPAMCL0JSSQ4mvH?p=preview))
|
||||
@@ -172,10 +172,10 @@ export class InstantiationError extends WrappedException {
|
||||
* expect(() => Injector.resolveAndCreate(["not a type"])).toThrowError();
|
||||
* ```
|
||||
*/
|
||||
export class InvalidBindingError extends BaseException {
|
||||
constructor(binding) {
|
||||
super("Invalid binding - only instances of Binding and Type are allowed, got: " +
|
||||
binding.toString());
|
||||
export class InvalidProviderError extends BaseException {
|
||||
constructor(provider) {
|
||||
super("Invalid provider - only instances of Provider and Type are allowed, got: " +
|
||||
provider.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -246,20 +246,20 @@ export class OutOfBoundsError extends BaseException {
|
||||
|
||||
// TODO: add a working example after alpha38 is released
|
||||
/**
|
||||
* Thrown when a multi binding and a regular binding are bound to the same token.
|
||||
* Thrown when a multi provider and a regular provider are bound to the same token.
|
||||
*
|
||||
* ### Example
|
||||
*
|
||||
* ```typescript
|
||||
* expect(() => Injector.resolveAndCreate([
|
||||
* new Binding("Strings", {toValue: "string1", multi: true}),
|
||||
* new Binding("Strings", {toValue: "string2", multi: false})
|
||||
* new Provider("Strings", {toValue: "string1", multi: true}),
|
||||
* new Provider("Strings", {toValue: "string2", multi: false})
|
||||
* ])).toThrowError();
|
||||
* ```
|
||||
*/
|
||||
export class MixingMultiBindingsWithRegularBindings extends BaseException {
|
||||
constructor(binding1, binding2) {
|
||||
super("Cannot mix multi bindings and regular bindings, got: " + binding1.toString() + " " +
|
||||
binding2.toString());
|
||||
export class MixingMultiProvidersWithRegularProvidersError extends BaseException {
|
||||
constructor(provider1, provider2) {
|
||||
super("Cannot mix multi providers and regular providers, got: " + provider1.toString() + " " +
|
||||
provider2.toString());
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -16,7 +16,7 @@ export {TypeLiteral} from './type_literal';
|
||||
* injector to store created objects in a more efficient way.
|
||||
*
|
||||
* `Key` should not be created directly. {@link Injector} creates keys automatically when resolving
|
||||
* bindings.
|
||||
* providers.
|
||||
*/
|
||||
export class Key {
|
||||
/**
|
||||
|
||||
@@ -17,7 +17,7 @@ import {CONST, CONST_EXPR, stringify, isBlank, isPresent} from "angular2/src/cor
|
||||
* }
|
||||
*
|
||||
* var injector = Injector.resolveAndCreate([
|
||||
* bind("MyEngine").toClass(Engine),
|
||||
* provide("MyEngine", {asClass: Engine}),
|
||||
* Car
|
||||
* ]);
|
||||
*
|
||||
@@ -212,7 +212,7 @@ export class SkipSelfMetadata {
|
||||
*
|
||||
* @Component({
|
||||
* selector: 'parent-cmp',
|
||||
* bindings: [HostService]
|
||||
* providers: [HostService]
|
||||
* })
|
||||
* @View({
|
||||
* template: `
|
||||
@@ -225,7 +225,7 @@ export class SkipSelfMetadata {
|
||||
*
|
||||
* @Component({
|
||||
* selector: 'app',
|
||||
* bindings: [OtherService]
|
||||
* providers: [OtherService]
|
||||
* })
|
||||
* @View({
|
||||
* template: `
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
import {CONST} from 'angular2/src/core/facade/lang';
|
||||
|
||||
/**
|
||||
* Creates a token that can be used in a DI Binding.
|
||||
* Creates a token that can be used in a DI Provider.
|
||||
*
|
||||
* ### Example ([live demo](http://plnkr.co/edit/Ys9ezXpj2Mnoy3Uc8KBp?p=preview))
|
||||
*
|
||||
* ```typescript
|
||||
* var t = new OpaqueToken("binding");
|
||||
* var t = new OpaqueToken("value");
|
||||
*
|
||||
* var injector = Injector.resolveAndCreate([
|
||||
* bind(t).toValue("bindingValue")
|
||||
* provide(t, {asValue: "providedValue"})
|
||||
* ]);
|
||||
*
|
||||
* expect(injector.get(t)).toEqual("bindingValue");
|
||||
* ```
|
||||
*
|
||||
* Using an `OpaqueToken` is preferable to using strings as tokens because of possible collisions
|
||||
* caused by multiple bindings using the same string as two different tokens.
|
||||
* caused by multiple providers using the same string as two different tokens.
|
||||
*
|
||||
* Using an `OpaqueToken` is preferable to using an `Object` as tokens because it provides better
|
||||
* error messages.
|
||||
|
||||
+160
-105
File diff suppressed because it is too large
Load Diff
@@ -27,7 +27,7 @@ class _ArrayLogger {
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* bootstrap(MyApp, [bind(ExceptionHandler).toClass(MyExceptionHandler)])
|
||||
* bootstrap(MyApp, [provide(ExceptionHandler, {asClass: MyExceptionHandler})])
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
|
||||
@@ -41,12 +41,17 @@ import {FormBuilder} from './forms/form_builder';
|
||||
import {CONST_EXPR, Type} from './facade/lang';
|
||||
|
||||
/**
|
||||
* Shorthand set of bindings used for building Angular forms.
|
||||
* Shorthand set of providers used for building Angular forms.
|
||||
*
|
||||
* ### Example:
|
||||
*
|
||||
* ```typescript
|
||||
* bootstrap(MyApp, [FORM_BINDINGS]);
|
||||
* bootstrap(MyApp, [FORM_PROVIDERS]);
|
||||
* ```
|
||||
*/
|
||||
export const FORM_BINDINGS: Type[] = CONST_EXPR([FormBuilder]);
|
||||
export const FORM_PROVIDERS: Type[] = CONST_EXPR([FormBuilder]);
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
export const FORM_BINDINGS = FORM_PROVIDERS;
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import {Directive} from 'angular2/src/core/metadata';
|
||||
import {Renderer} from 'angular2/src/core/render';
|
||||
import {ElementRef} from 'angular2/src/core/linker';
|
||||
import {Self, forwardRef, Binding} from 'angular2/src/core/di';
|
||||
import {Self, forwardRef, Provider} from 'angular2/src/core/di';
|
||||
|
||||
import {NG_VALUE_ACCESSOR, ControlValueAccessor} from './control_value_accessor';
|
||||
import {CONST_EXPR} from 'angular2/src/core/facade/lang';
|
||||
import {setProperty} from './shared';
|
||||
|
||||
const CHECKBOX_VALUE_ACCESSOR = CONST_EXPR(new Binding(
|
||||
const CHECKBOX_VALUE_ACCESSOR = CONST_EXPR(new Provider(
|
||||
NG_VALUE_ACCESSOR, {toAlias: forwardRef(() => CheckboxControlValueAccessor), multi: true}));
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import {Directive} from 'angular2/src/core/metadata';
|
||||
import {ElementRef} from 'angular2/src/core/linker';
|
||||
import {Renderer} from 'angular2/src/core/render';
|
||||
import {Self, forwardRef, Binding} from 'angular2/src/core/di';
|
||||
import {Self, forwardRef, Provider} from 'angular2/src/core/di';
|
||||
import {NG_VALUE_ACCESSOR, ControlValueAccessor} from './control_value_accessor';
|
||||
import {isBlank, CONST_EXPR} from 'angular2/src/core/facade/lang';
|
||||
import {setProperty} from './shared';
|
||||
|
||||
const DEFAULT_VALUE_ACCESSOR = CONST_EXPR(
|
||||
new Binding(NG_VALUE_ACCESSOR, {toAlias: forwardRef(() => DefaultValueAccessor), multi: true}));
|
||||
const DEFAULT_VALUE_ACCESSOR = CONST_EXPR(new Provider(
|
||||
NG_VALUE_ACCESSOR, {toAlias: forwardRef(() => DefaultValueAccessor), multi: true}));
|
||||
|
||||
/**
|
||||
* The default accessor for writing a value and listening to changes that is used by the
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {OnInit, OnDestroy} from 'angular2/lifecycle_hooks';
|
||||
import {Directive} from 'angular2/src/core/metadata';
|
||||
import {Inject, Host, SkipSelf, forwardRef, Binding} from 'angular2/src/core/di';
|
||||
import {Inject, Host, SkipSelf, forwardRef, Provider} from 'angular2/src/core/di';
|
||||
import {ListWrapper} from 'angular2/src/core/facade/collection';
|
||||
import {CONST_EXPR} from 'angular2/src/core/facade/lang';
|
||||
|
||||
@@ -10,7 +10,7 @@ import {ControlGroup} from '../model';
|
||||
import {Form} from './form_interface';
|
||||
|
||||
const controlGroupBinding =
|
||||
CONST_EXPR(new Binding(ControlContainer, {toAlias: forwardRef(() => NgControlGroup)}));
|
||||
CONST_EXPR(new Provider(ControlContainer, {toAlias: forwardRef(() => NgControlGroup)}));
|
||||
|
||||
/**
|
||||
* Creates and binds a control group to a DOM element.
|
||||
|
||||
@@ -3,7 +3,7 @@ import {EventEmitter, ObservableWrapper} from 'angular2/src/core/facade/async';
|
||||
import {OnChanges, OnDestroy} from 'angular2/lifecycle_hooks';
|
||||
import {SimpleChange} from 'angular2/src/core/change_detection';
|
||||
import {Query, Directive} from 'angular2/src/core/metadata';
|
||||
import {forwardRef, Host, SkipSelf, Binding, Inject, Optional} from 'angular2/src/core/di';
|
||||
import {forwardRef, Host, SkipSelf, Provider, Inject, Optional} from 'angular2/src/core/di';
|
||||
|
||||
import {ControlContainer} from './control_container';
|
||||
import {NgControl} from './ng_control';
|
||||
@@ -14,7 +14,7 @@ import {Validators, NG_VALIDATORS} from '../validators';
|
||||
|
||||
|
||||
const controlNameBinding =
|
||||
CONST_EXPR(new Binding(NgControl, {toAlias: forwardRef(() => NgControlName)}));
|
||||
CONST_EXPR(new Provider(NgControl, {toAlias: forwardRef(() => NgControlName)}));
|
||||
|
||||
/**
|
||||
* Creates and binds a control with a specified name to a DOM element.
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
import {StringMapWrapper, ListWrapper} from 'angular2/src/core/facade/collection';
|
||||
import {isPresent, isBlank, CONST_EXPR} from 'angular2/src/core/facade/lang';
|
||||
import {Directive} from 'angular2/src/core/metadata';
|
||||
import {forwardRef, Binding} from 'angular2/src/core/di';
|
||||
import {forwardRef, Provider} from 'angular2/src/core/di';
|
||||
import {NgControl} from './ng_control';
|
||||
import {Form} from './form_interface';
|
||||
import {NgControlGroup} from './ng_control_group';
|
||||
@@ -15,8 +15,8 @@ import {ControlContainer} from './control_container';
|
||||
import {AbstractControl, ControlGroup, Control} from '../model';
|
||||
import {setUpControl} from './shared';
|
||||
|
||||
const formDirectiveBinding =
|
||||
CONST_EXPR(new Binding(ControlContainer, {toAlias: forwardRef(() => NgForm)}));
|
||||
const formDirectiveProvider =
|
||||
CONST_EXPR(new Provider(ControlContainer, {toAlias: forwardRef(() => NgForm)}));
|
||||
|
||||
/**
|
||||
* If `NgForm` is bound in a component, `<form>` elements in that component will be
|
||||
@@ -81,7 +81,7 @@ const formDirectiveBinding =
|
||||
*/
|
||||
@Directive({
|
||||
selector: 'form:not([ng-no-form]):not([ng-form-model]),ng-form,[ng-form]',
|
||||
bindings: [formDirectiveBinding],
|
||||
bindings: [formDirectiveProvider],
|
||||
host: {
|
||||
'(submit)': 'onSubmit()',
|
||||
},
|
||||
|
||||
@@ -3,7 +3,7 @@ import {EventEmitter, ObservableWrapper} from 'angular2/src/core/facade/async';
|
||||
import {OnChanges} from 'angular2/lifecycle_hooks';
|
||||
import {SimpleChange} from 'angular2/src/core/change_detection';
|
||||
import {Query, Directive} from 'angular2/src/core/metadata';
|
||||
import {forwardRef, Binding, Inject, Optional} from 'angular2/src/core/di';
|
||||
import {forwardRef, Provider, Inject, Optional} from 'angular2/src/core/di';
|
||||
import {NgControl} from './ng_control';
|
||||
import {Control} from '../model';
|
||||
import {Validators, NG_VALIDATORS} from '../validators';
|
||||
@@ -11,7 +11,7 @@ import {ControlValueAccessor, NG_VALUE_ACCESSOR} from './control_value_accessor'
|
||||
import {setUpControl, isPropertyUpdated, selectValueAccessor} from './shared';
|
||||
|
||||
const formControlBinding =
|
||||
CONST_EXPR(new Binding(NgControl, {toAlias: forwardRef(() => NgFormControl)}));
|
||||
CONST_EXPR(new Provider(NgControl, {toAlias: forwardRef(() => NgFormControl)}));
|
||||
|
||||
/**
|
||||
* Binds an existing {@link Control} to a DOM element.
|
||||
|
||||
@@ -4,7 +4,7 @@ import {ObservableWrapper, EventEmitter} from 'angular2/src/core/facade/async';
|
||||
|
||||
import {OnChanges} from 'angular2/lifecycle_hooks';
|
||||
import {Directive} from 'angular2/src/core/metadata';
|
||||
import {forwardRef, Binding} from 'angular2/src/core/di';
|
||||
import {forwardRef, Provider} from 'angular2/src/core/di';
|
||||
import {NgControl} from './ng_control';
|
||||
import {NgControlGroup} from './ng_control_group';
|
||||
import {ControlContainer} from './control_container';
|
||||
@@ -12,8 +12,8 @@ import {Form} from './form_interface';
|
||||
import {Control, ControlGroup} from '../model';
|
||||
import {setUpControl} from './shared';
|
||||
|
||||
const formDirectiveBinding =
|
||||
CONST_EXPR(new Binding(ControlContainer, {toAlias: forwardRef(() => NgFormModel)}));
|
||||
const formDirectiveProvider =
|
||||
CONST_EXPR(new Provider(ControlContainer, {toAlias: forwardRef(() => NgFormModel)}));
|
||||
|
||||
/**
|
||||
* Binds an existing control group to a DOM element.
|
||||
@@ -91,7 +91,7 @@ const formDirectiveBinding =
|
||||
*/
|
||||
@Directive({
|
||||
selector: '[ng-form-model]',
|
||||
bindings: [formDirectiveBinding],
|
||||
bindings: [formDirectiveProvider],
|
||||
inputs: ['form: ng-form-model'],
|
||||
host: {'(submit)': 'onSubmit()'},
|
||||
outputs: ['ngSubmit'],
|
||||
|
||||
@@ -3,14 +3,15 @@ import {EventEmitter, ObservableWrapper} from 'angular2/src/core/facade/async';
|
||||
import {OnChanges} from 'angular2/lifecycle_hooks';
|
||||
import {SimpleChange} from 'angular2/src/core/change_detection';
|
||||
import {Query, Directive} from 'angular2/src/core/metadata';
|
||||
import {forwardRef, Binding, Inject, Optional} from 'angular2/src/core/di';
|
||||
import {forwardRef, Provider, Inject, Optional} from 'angular2/src/core/di';
|
||||
import {ControlValueAccessor, NG_VALUE_ACCESSOR} from './control_value_accessor';
|
||||
import {NgControl} from './ng_control';
|
||||
import {Control} from '../model';
|
||||
import {Validators, NG_VALIDATORS} from '../validators';
|
||||
import {setUpControl, isPropertyUpdated, selectValueAccessor} from './shared';
|
||||
|
||||
const formControlBinding = CONST_EXPR(new Binding(NgControl, {toAlias: forwardRef(() => NgModel)}));
|
||||
const formControlBinding =
|
||||
CONST_EXPR(new Provider(NgControl, {toAlias: forwardRef(() => NgModel)}));
|
||||
|
||||
/**
|
||||
* Binds a domain model to a form control.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {Self, forwardRef, Binding} from 'angular2/src/core/di';
|
||||
import {Self, forwardRef, Provider} from 'angular2/src/core/di';
|
||||
import {Renderer} from 'angular2/src/core/render';
|
||||
import {ElementRef, QueryList} from 'angular2/src/core/linker';
|
||||
import {Query, Directive} from 'angular2/src/core/metadata';
|
||||
@@ -8,7 +8,7 @@ import {NG_VALUE_ACCESSOR, ControlValueAccessor} from './control_value_accessor'
|
||||
import {CONST_EXPR} from 'angular2/src/core/facade/lang';
|
||||
import {setProperty} from './shared';
|
||||
|
||||
const SELECT_VALUE_ACCESSOR = CONST_EXPR(new Binding(
|
||||
const SELECT_VALUE_ACCESSOR = CONST_EXPR(new Provider(
|
||||
NG_VALUE_ACCESSOR, {toAlias: forwardRef(() => SelectControlValueAccessor), multi: true}));
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import {forwardRef, Binding, OpaqueToken} from 'angular2/src/core/di';
|
||||
import {forwardRef, Provider, OpaqueToken} from 'angular2/src/core/di';
|
||||
import {CONST_EXPR} from 'angular2/src/core/facade/lang';
|
||||
import {Directive} from 'angular2/src/core/metadata';
|
||||
import {Validators, NG_VALIDATORS} from '../validators';
|
||||
|
||||
const DEFAULT_VALIDATORS =
|
||||
CONST_EXPR(new Binding(NG_VALIDATORS, {toValue: Validators.required, multi: true}));
|
||||
CONST_EXPR(new Provider(NG_VALIDATORS, {toValue: Validators.required, multi: true}));
|
||||
|
||||
@Directive({
|
||||
selector: '[required][ng-control],[required][ng-form-control],[required][ng-model]',
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user