refactor: rename all const to UPPER_CASE

Closes #3573

BREAKING CHANGE

Rename:
- `appComponentTypeToken` => `APP_COMPONENT`
- `coreDirectives` => `CORE_DIRECTIVES`
- `formDirectives` => `FORM_DIRECTIVES`
- `formInjectables` => `FORM_BINDINGS`
- `httpInjectables` => `HTTP_BINDINGS`
- `jsonpInjectables` => `JSONP_BINDINGS`
- `PROTO_CHANGE_DETECTOR_KEY` => `PROTO_CHANGE_DETECTOR`
- `appComponentRefPromiseToken` => `APP_COMPONENT_REF_PROMISE`
- `appComponentTypeToken` => `APP_COMPONENT`
- `undefinedValue` => `UNDEFINED`
- `formDirectives` => `FORM_DIRECTIVES`
- `DOCUMENT_TOKEN` => `DOCUMENT`
- `APP_ID_TOKEN` => `APP_ID`
- `MAX_IN_MEMORY_ELEMENTS_PER_TEMPLATE_TOKEN` => `MAX_IN_MEMORY_ELEMENTS_PER_TEMPLATE`
- `appBaseHrefToken` => `APP_BASE_HREF`
This commit is contained in:
Misko Hevery 2015-08-10 21:42:47 -07:00
parent 1d65b38b28
commit 60af19f0e1
54 changed files with 203 additions and 205 deletions

View File

@ -3,7 +3,7 @@
* @description * @description
* Define angular core API here. * Define angular core API here.
*/ */
export {appComponentTypeToken} from 'angular2/src/core/application_tokens'; export {APP_COMPONENT} from 'angular2/src/core/application_tokens';
export {ApplicationRef} from 'angular2/src/core/application_common'; export {ApplicationRef} from 'angular2/src/core/application_common';
export {Type} from 'angular2/src/facade/lang'; export {Type} from 'angular2/src/facade/lang';

View File

@ -26,7 +26,7 @@ export {
PUBLIC_AND_PRIVATE, PUBLIC_AND_PRIVATE,
PUBLIC, PUBLIC,
PRIVATE, PRIVATE,
undefinedValue UNDEFINED
} from './src/di/injector'; } from './src/di/injector';
export {Binding, BindingBuilder, ResolvedBinding, Dependency, bind} from './src/di/binding'; export {Binding, BindingBuilder, ResolvedBinding, Dependency, bind} from './src/di/binding';
export {Key, KeyRegistry, TypeLiteral} from './src/di/key'; export {Key, KeyRegistry, TypeLiteral} from './src/di/key';

View File

@ -60,5 +60,5 @@ export * from './src/directives/ng_switch';
* ``` * ```
* *
*/ */
export const coreDirectives: List<Type> = export const CORE_DIRECTIVES: List<Type> =
CONST_EXPR([NgClass, NgFor, NgIf, NgNonBindable, NgSwitch, NgSwitchWhen, NgSwitchDefault]); CONST_EXPR([NgClass, NgFor, NgIf, NgNonBindable, NgSwitch, NgSwitchWhen, NgSwitchDefault]);

View File

@ -31,7 +31,7 @@ export {
NgSelectOption, NgSelectOption,
SelectControlValueAccessor SelectControlValueAccessor
} from './src/forms/directives/select_control_value_accessor'; } from './src/forms/directives/select_control_value_accessor';
export {formDirectives} from './src/forms/directives'; export {FORM_DIRECTIVES} from './src/forms/directives';
export {Validators} from './src/forms/validators'; export {Validators} from './src/forms/validators';
export {NgValidator, NgRequiredValidator} from './src/forms/directives/validators'; export {NgValidator, NgRequiredValidator} from './src/forms/directives/validators';
export {FormBuilder} from './src/forms/form_builder'; export {FormBuilder} from './src/forms/form_builder';
@ -39,4 +39,4 @@ export {FormBuilder} from './src/forms/form_builder';
import {FormBuilder} from './src/forms/form_builder'; import {FormBuilder} from './src/forms/form_builder';
import {CONST_EXPR, Type} from './src/facade/lang'; import {CONST_EXPR, Type} from './src/facade/lang';
export const formInjectables: List<Type> = CONST_EXPR([FormBuilder]); export const FORM_BINDINGS: List<Type> = CONST_EXPR([FormBuilder]);

View File

@ -15,8 +15,8 @@ export {
RenderFragmentRef, RenderFragmentRef,
RenderViewWithFragments, RenderViewWithFragments,
ViewDefinition, ViewDefinition,
DOCUMENT_TOKEN, DOCUMENT,
APP_ID_TOKEN, APP_ID,
DOM_REFLECT_PROPERTIES_AS_ATTRIBUTES, DOM_REFLECT_PROPERTIES_AS_ATTRIBUTES,
MAX_IN_MEMORY_ELEMENTS_PER_TEMPLATE_TOKEN MAX_IN_MEMORY_ELEMENTS_PER_TEMPLATE
} from './src/render/render'; } from './src/render/render';

View File

@ -13,7 +13,7 @@ export {RouteRegistry} from './src/router/route_registry';
export {LocationStrategy} from './src/router/location_strategy'; export {LocationStrategy} from './src/router/location_strategy';
export {HashLocationStrategy} from './src/router/hash_location_strategy'; export {HashLocationStrategy} from './src/router/hash_location_strategy';
export {HTML5LocationStrategy} from './src/router/html5_location_strategy'; export {HTML5LocationStrategy} from './src/router/html5_location_strategy';
export {Location, appBaseHrefToken} from './src/router/location'; export {Location, APP_BASE_HREF} from './src/router/location';
export {Pipeline} from './src/router/pipeline'; export {Pipeline} from './src/router/pipeline';
export * from './src/router/route_config_decorator'; export * from './src/router/route_config_decorator';
export * from './src/router/route_definition'; export * from './src/router/route_definition';
@ -31,7 +31,7 @@ import {RouterLink} from './src/router/router_link';
import {RouteRegistry} from './src/router/route_registry'; import {RouteRegistry} from './src/router/route_registry';
import {Pipeline} from './src/router/pipeline'; import {Pipeline} from './src/router/pipeline';
import {Location} from './src/router/location'; import {Location} from './src/router/location';
import {appComponentTypeToken} from './src/core/application_tokens'; import {APP_COMPONENT} from './src/core/application_tokens';
import {bind} from './di'; import {bind} from './di';
import {CONST_EXPR} from './src/facade/lang'; import {CONST_EXPR} from './src/facade/lang';
import {List} from './src/facade/collection'; import {List} from './src/facade/collection';
@ -46,5 +46,5 @@ export var routerInjectables: List<any> = [
bind(Router) bind(Router)
.toFactory((registry, pipeline, location, .toFactory((registry, pipeline, location,
appRoot) => { return new RootRouter(registry, pipeline, location, appRoot);}, appRoot) => { return new RootRouter(registry, pipeline, location, appRoot);},
[RouteRegistry, Pipeline, Location, appComponentTypeToken]) [RouteRegistry, Pipeline, Location, APP_COMPONENT])
]; ];

View File

@ -72,7 +72,7 @@ export const defaultKeyValueDiffers = CONST_EXPR(new KeyValueDiffers(keyValDiff)
// dart2js. See https://github.com/dart-lang/sdk/issues/23630 for details. // dart2js. See https://github.com/dart-lang/sdk/issues/23630 for details.
export var preGeneratedProtoDetectors: StringMap<string, Function> = {}; export var preGeneratedProtoDetectors: StringMap<string, Function> = {};
export const PROTO_CHANGE_DETECTOR_KEY = CONST_EXPR(new OpaqueToken('ProtoChangeDetectors')); export const PROTO_CHANGE_DETECTOR = CONST_EXPR(new OpaqueToken('ProtoChangeDetectors'));
/** /**
* Implements change detection using a map of pregenerated proto detectors. * Implements change detection using a map of pregenerated proto detectors.
@ -82,7 +82,7 @@ export class PreGeneratedChangeDetection extends ChangeDetection {
_dynamicChangeDetection: ChangeDetection; _dynamicChangeDetection: ChangeDetection;
_protoChangeDetectorFactories: StringMap<string, Function>; _protoChangeDetectorFactories: StringMap<string, Function>;
constructor(@Inject(PROTO_CHANGE_DETECTOR_KEY) @Optional() protoChangeDetectorsForTest?: constructor(@Inject(PROTO_CHANGE_DETECTOR) @Optional() protoChangeDetectorsForTest?:
StringMap<string, Function>) { StringMap<string, Function>) {
super(); super();
this._dynamicChangeDetection = new DynamicChangeDetection(); this._dynamicChangeDetection = new DynamicChangeDetection();

View File

@ -60,11 +60,11 @@ import {ProtoViewFactory} from 'angular2/src/core/compiler/proto_view_factory';
import {Renderer, RenderCompiler} from 'angular2/src/render/api'; import {Renderer, RenderCompiler} from 'angular2/src/render/api';
import { import {
DomRenderer, DomRenderer,
DOCUMENT_TOKEN, DOCUMENT,
DOM_REFLECT_PROPERTIES_AS_ATTRIBUTES, DOM_REFLECT_PROPERTIES_AS_ATTRIBUTES,
DefaultDomCompiler, DefaultDomCompiler,
APP_ID_RANDOM_BINDING, APP_ID_RANDOM_BINDING,
MAX_IN_MEMORY_ELEMENTS_PER_TEMPLATE_TOKEN, MAX_IN_MEMORY_ELEMENTS_PER_TEMPLATE,
TemplateCloner TemplateCloner
} from 'angular2/src/render/render'; } from 'angular2/src/render/render';
import {ElementSchemaRegistry} from 'angular2/src/render/dom/schema/element_schema_registry'; import {ElementSchemaRegistry} from 'angular2/src/render/dom/schema/element_schema_registry';
@ -74,7 +74,7 @@ import {
DomSharedStylesHost DomSharedStylesHost
} from 'angular2/src/render/dom/view/shared_styles_host'; } from 'angular2/src/render/dom/view/shared_styles_host';
import {internalView} from 'angular2/src/core/compiler/view_ref'; import {internalView} from 'angular2/src/core/compiler/view_ref';
import {appComponentRefPromiseToken, appComponentTypeToken} from './application_tokens'; import {APP_COMPONENT_REF_PROMISE, APP_COMPONENT} from './application_tokens';
import {wtfInit} from '../profile/wtf_init'; import {wtfInit} from '../profile/wtf_init';
var _rootInjector: Injector; var _rootInjector: Injector;
@ -90,11 +90,11 @@ function _injectorBindings(appComponentType): List<Type | Binding | List<any>> {
bestChangeDetection = JitChangeDetection; bestChangeDetection = JitChangeDetection;
} }
return [ return [
bind(DOCUMENT_TOKEN) bind(DOCUMENT)
.toValue(DOM.defaultDoc()), .toValue(DOM.defaultDoc()),
bind(DOM_REFLECT_PROPERTIES_AS_ATTRIBUTES).toValue(false), bind(DOM_REFLECT_PROPERTIES_AS_ATTRIBUTES).toValue(false),
bind(appComponentTypeToken).toValue(appComponentType), bind(APP_COMPONENT).toValue(appComponentType),
bind(appComponentRefPromiseToken) bind(APP_COMPONENT_REF_PROMISE)
.toFactory( .toFactory(
(dynamicComponentLoader, injector, testability, registry) => { (dynamicComponentLoader, injector, testability, registry) => {
// TODO(rado): investigate whether to support bindings on root component. // TODO(rado): investigate whether to support bindings on root component.
@ -107,7 +107,7 @@ function _injectorBindings(appComponentType): List<Type | Binding | List<any>> {
[DynamicComponentLoader, Injector, Testability, TestabilityRegistry]), [DynamicComponentLoader, Injector, Testability, TestabilityRegistry]),
bind(appComponentType) bind(appComponentType)
.toFactory((p: Promise<any>) => p.then(ref => ref.instance), [appComponentRefPromiseToken]), .toFactory((p: Promise<any>) => p.then(ref => ref.instance), [APP_COMPONENT_REF_PROMISE]),
bind(LifeCycle).toFactory((exceptionHandler) => new LifeCycle(null, assertionsEnabled()), bind(LifeCycle).toFactory((exceptionHandler) => new LifeCycle(null, assertionsEnabled()),
[ExceptionHandler]), [ExceptionHandler]),
bind(EventManager) bind(EventManager)
@ -122,7 +122,7 @@ function _injectorBindings(appComponentType): List<Type | Binding | List<any>> {
bind(Renderer).toAlias(DomRenderer), bind(Renderer).toAlias(DomRenderer),
APP_ID_RANDOM_BINDING, APP_ID_RANDOM_BINDING,
TemplateCloner, TemplateCloner,
bind(MAX_IN_MEMORY_ELEMENTS_PER_TEMPLATE_TOKEN).toValue(20), bind(MAX_IN_MEMORY_ELEMENTS_PER_TEMPLATE).toValue(20),
DefaultDomCompiler, DefaultDomCompiler,
bind(ElementSchemaRegistry).toValue(new DomElementSchemaRegistry()), bind(ElementSchemaRegistry).toValue(new DomElementSchemaRegistry()),
bind(RenderCompiler).toAlias(DefaultDomCompiler), bind(RenderCompiler).toAlias(DefaultDomCompiler),
@ -305,7 +305,7 @@ export function commonBootstrap(
exceptionHandler = appInjector.get(ExceptionHandler); exceptionHandler = appInjector.get(ExceptionHandler);
zone.overrideOnErrorHandler((e, s) => exceptionHandler.call(e, s)); zone.overrideOnErrorHandler((e, s) => exceptionHandler.call(e, s));
var compRefToken: Promise<any> = appInjector.get(appComponentRefPromiseToken); var compRefToken: Promise<any> = appInjector.get(APP_COMPONENT_REF_PROMISE);
var tick = (componentRef) => { var tick = (componentRef) => {
var appChangeDetector = internalView(componentRef.hostView).changeDetector; var appChangeDetector = internalView(componentRef.hostView).changeDetector;
// retrieve life cycle: may have already been created if injected in root component // retrieve life cycle: may have already been created if injected in root component

View File

@ -4,7 +4,7 @@ import {CONST_EXPR} from 'angular2/src/facade/lang';
/** /**
* @private * @private
*/ */
export const appComponentRefPromiseToken = CONST_EXPR(new OpaqueToken('Promise<ComponentRef>')); export const APP_COMPONENT_REF_PROMISE = CONST_EXPR(new OpaqueToken('Promise<ComponentRef>'));
/** /**
* An opaque token representing the application root type in the {@link Injector}. * An opaque token representing the application root type in the {@link Injector}.
@ -22,4 +22,4 @@ export const appComponentRefPromiseToken = CONST_EXPR(new OpaqueToken('Promise<C
* *
* ``` * ```
*/ */
export const appComponentTypeToken: OpaqueToken = CONST_EXPR(new OpaqueToken('RootComponent')); export const APP_COMPONENT: OpaqueToken = CONST_EXPR(new OpaqueToken('AppComponent'));

View File

@ -15,7 +15,7 @@ import {
PUBLIC_AND_PRIVATE, PUBLIC_AND_PRIVATE,
PUBLIC, PUBLIC,
PRIVATE, PRIVATE,
undefinedValue, UNDEFINED,
Key, Key,
Dependency, Dependency,
bind, bind,
@ -645,7 +645,7 @@ export class ElementInjector extends TreeNode<ElementInjector> implements Depend
} }
} }
return undefinedValue; return UNDEFINED;
} }
private _buildAttribute(dep: DirectiveDependency): string { private _buildAttribute(dep: DirectiveDependency): string {
@ -892,41 +892,41 @@ class ElementInjectorInlineStrategy implements _ElementInjectorStrategy {
var p = i.protoStrategy; var p = i.protoStrategy;
i.resetConstructionCounter(); i.resetConstructionCounter();
if (p.binding0 instanceof DirectiveBinding && isPresent(p.keyId0) && i.obj0 === undefinedValue) if (p.binding0 instanceof DirectiveBinding && isPresent(p.keyId0) && i.obj0 === UNDEFINED)
i.obj0 = i.instantiateBinding(p.binding0, p.visibility0); i.obj0 = i.instantiateBinding(p.binding0, p.visibility0);
if (p.binding1 instanceof DirectiveBinding && isPresent(p.keyId1) && i.obj1 === undefinedValue) if (p.binding1 instanceof DirectiveBinding && isPresent(p.keyId1) && i.obj1 === UNDEFINED)
i.obj1 = i.instantiateBinding(p.binding1, p.visibility1); i.obj1 = i.instantiateBinding(p.binding1, p.visibility1);
if (p.binding2 instanceof DirectiveBinding && isPresent(p.keyId2) && i.obj2 === undefinedValue) if (p.binding2 instanceof DirectiveBinding && isPresent(p.keyId2) && i.obj2 === UNDEFINED)
i.obj2 = i.instantiateBinding(p.binding2, p.visibility2); i.obj2 = i.instantiateBinding(p.binding2, p.visibility2);
if (p.binding3 instanceof DirectiveBinding && isPresent(p.keyId3) && i.obj3 === undefinedValue) if (p.binding3 instanceof DirectiveBinding && isPresent(p.keyId3) && i.obj3 === UNDEFINED)
i.obj3 = i.instantiateBinding(p.binding3, p.visibility3); i.obj3 = i.instantiateBinding(p.binding3, p.visibility3);
if (p.binding4 instanceof DirectiveBinding && isPresent(p.keyId4) && i.obj4 === undefinedValue) if (p.binding4 instanceof DirectiveBinding && isPresent(p.keyId4) && i.obj4 === UNDEFINED)
i.obj4 = i.instantiateBinding(p.binding4, p.visibility4); i.obj4 = i.instantiateBinding(p.binding4, p.visibility4);
if (p.binding5 instanceof DirectiveBinding && isPresent(p.keyId5) && i.obj5 === undefinedValue) if (p.binding5 instanceof DirectiveBinding && isPresent(p.keyId5) && i.obj5 === UNDEFINED)
i.obj5 = i.instantiateBinding(p.binding5, p.visibility5); i.obj5 = i.instantiateBinding(p.binding5, p.visibility5);
if (p.binding6 instanceof DirectiveBinding && isPresent(p.keyId6) && i.obj6 === undefinedValue) if (p.binding6 instanceof DirectiveBinding && isPresent(p.keyId6) && i.obj6 === UNDEFINED)
i.obj6 = i.instantiateBinding(p.binding6, p.visibility6); i.obj6 = i.instantiateBinding(p.binding6, p.visibility6);
if (p.binding7 instanceof DirectiveBinding && isPresent(p.keyId7) && i.obj7 === undefinedValue) if (p.binding7 instanceof DirectiveBinding && isPresent(p.keyId7) && i.obj7 === UNDEFINED)
i.obj7 = i.instantiateBinding(p.binding7, p.visibility7); i.obj7 = i.instantiateBinding(p.binding7, p.visibility7);
if (p.binding8 instanceof DirectiveBinding && isPresent(p.keyId8) && i.obj8 === undefinedValue) if (p.binding8 instanceof DirectiveBinding && isPresent(p.keyId8) && i.obj8 === UNDEFINED)
i.obj8 = i.instantiateBinding(p.binding8, p.visibility8); i.obj8 = i.instantiateBinding(p.binding8, p.visibility8);
if (p.binding9 instanceof DirectiveBinding && isPresent(p.keyId9) && i.obj9 === undefinedValue) if (p.binding9 instanceof DirectiveBinding && isPresent(p.keyId9) && i.obj9 === UNDEFINED)
i.obj9 = i.instantiateBinding(p.binding9, p.visibility9); i.obj9 = i.instantiateBinding(p.binding9, p.visibility9);
} }
dehydrate() { dehydrate() {
var i = this.injectorStrategy; var i = this.injectorStrategy;
i.obj0 = undefinedValue; i.obj0 = UNDEFINED;
i.obj1 = undefinedValue; i.obj1 = UNDEFINED;
i.obj2 = undefinedValue; i.obj2 = UNDEFINED;
i.obj3 = undefinedValue; i.obj3 = UNDEFINED;
i.obj4 = undefinedValue; i.obj4 = UNDEFINED;
i.obj5 = undefinedValue; i.obj5 = UNDEFINED;
i.obj6 = undefinedValue; i.obj6 = UNDEFINED;
i.obj7 = undefinedValue; i.obj7 = UNDEFINED;
i.obj8 = undefinedValue; i.obj8 = UNDEFINED;
i.obj9 = undefinedValue; i.obj9 = UNDEFINED;
} }
callOnDestroy(): void { callOnDestroy(): void {
@ -1012,43 +1012,43 @@ class ElementInjectorInlineStrategy implements _ElementInjectorStrategy {
var p = i.protoStrategy; var p = i.protoStrategy;
if (isPresent(p.binding0) && p.binding0.key.token === query.selector) { if (isPresent(p.binding0) && p.binding0.key.token === query.selector) {
if (i.obj0 === undefinedValue) i.obj0 = i.instantiateBinding(p.binding0, p.visibility0); if (i.obj0 === UNDEFINED) i.obj0 = i.instantiateBinding(p.binding0, p.visibility0);
list.push(i.obj0); list.push(i.obj0);
} }
if (isPresent(p.binding1) && p.binding1.key.token === query.selector) { if (isPresent(p.binding1) && p.binding1.key.token === query.selector) {
if (i.obj1 === undefinedValue) i.obj1 = i.instantiateBinding(p.binding1, p.visibility1); if (i.obj1 === UNDEFINED) i.obj1 = i.instantiateBinding(p.binding1, p.visibility1);
list.push(i.obj1); list.push(i.obj1);
} }
if (isPresent(p.binding2) && p.binding2.key.token === query.selector) { if (isPresent(p.binding2) && p.binding2.key.token === query.selector) {
if (i.obj2 === undefinedValue) i.obj2 = i.instantiateBinding(p.binding2, p.visibility2); if (i.obj2 === UNDEFINED) i.obj2 = i.instantiateBinding(p.binding2, p.visibility2);
list.push(i.obj2); list.push(i.obj2);
} }
if (isPresent(p.binding3) && p.binding3.key.token === query.selector) { if (isPresent(p.binding3) && p.binding3.key.token === query.selector) {
if (i.obj3 === undefinedValue) i.obj3 = i.instantiateBinding(p.binding3, p.visibility3); if (i.obj3 === UNDEFINED) i.obj3 = i.instantiateBinding(p.binding3, p.visibility3);
list.push(i.obj3); list.push(i.obj3);
} }
if (isPresent(p.binding4) && p.binding4.key.token === query.selector) { if (isPresent(p.binding4) && p.binding4.key.token === query.selector) {
if (i.obj4 === undefinedValue) i.obj4 = i.instantiateBinding(p.binding4, p.visibility4); if (i.obj4 === UNDEFINED) i.obj4 = i.instantiateBinding(p.binding4, p.visibility4);
list.push(i.obj4); list.push(i.obj4);
} }
if (isPresent(p.binding5) && p.binding5.key.token === query.selector) { if (isPresent(p.binding5) && p.binding5.key.token === query.selector) {
if (i.obj5 === undefinedValue) i.obj5 = i.instantiateBinding(p.binding5, p.visibility5); if (i.obj5 === UNDEFINED) i.obj5 = i.instantiateBinding(p.binding5, p.visibility5);
list.push(i.obj5); list.push(i.obj5);
} }
if (isPresent(p.binding6) && p.binding6.key.token === query.selector) { if (isPresent(p.binding6) && p.binding6.key.token === query.selector) {
if (i.obj6 === undefinedValue) i.obj6 = i.instantiateBinding(p.binding6, p.visibility6); if (i.obj6 === UNDEFINED) i.obj6 = i.instantiateBinding(p.binding6, p.visibility6);
list.push(i.obj6); list.push(i.obj6);
} }
if (isPresent(p.binding7) && p.binding7.key.token === query.selector) { if (isPresent(p.binding7) && p.binding7.key.token === query.selector) {
if (i.obj7 === undefinedValue) i.obj7 = i.instantiateBinding(p.binding7, p.visibility7); if (i.obj7 === UNDEFINED) i.obj7 = i.instantiateBinding(p.binding7, p.visibility7);
list.push(i.obj7); list.push(i.obj7);
} }
if (isPresent(p.binding8) && p.binding8.key.token === query.selector) { if (isPresent(p.binding8) && p.binding8.key.token === query.selector) {
if (i.obj8 === undefinedValue) i.obj8 = i.instantiateBinding(p.binding8, p.visibility8); if (i.obj8 === UNDEFINED) i.obj8 = i.instantiateBinding(p.binding8, p.visibility8);
list.push(i.obj8); list.push(i.obj8);
} }
if (isPresent(p.binding9) && p.binding9.key.token === query.selector) { if (isPresent(p.binding9) && p.binding9.key.token === query.selector) {
if (i.obj9 === undefinedValue) i.obj9 = i.instantiateBinding(p.binding9, p.visibility9); if (i.obj9 === UNDEFINED) i.obj9 = i.instantiateBinding(p.binding9, p.visibility9);
list.push(i.obj9); list.push(i.obj9);
} }
} }
@ -1072,7 +1072,7 @@ class ElementInjectorDynamicStrategy implements _ElementInjectorStrategy {
for (var i = 0; i < p.keyIds.length; i++) { for (var i = 0; i < p.keyIds.length; i++) {
if (p.bindings[i] instanceof DirectiveBinding && isPresent(p.keyIds[i]) && if (p.bindings[i] instanceof DirectiveBinding && isPresent(p.keyIds[i]) &&
inj.objs[i] === undefinedValue) { inj.objs[i] === UNDEFINED) {
inj.objs[i] = inj.instantiateBinding(p.bindings[i], p.visibilities[i]); inj.objs[i] = inj.instantiateBinding(p.bindings[i], p.visibilities[i]);
} }
} }
@ -1080,7 +1080,7 @@ class ElementInjectorDynamicStrategy implements _ElementInjectorStrategy {
dehydrate(): void { dehydrate(): void {
var inj = this.injectorStrategy; var inj = this.injectorStrategy;
ListWrapper.fill(inj.objs, undefinedValue); ListWrapper.fill(inj.objs, UNDEFINED);
} }
callOnDestroy(): void { callOnDestroy(): void {
@ -1119,7 +1119,7 @@ class ElementInjectorDynamicStrategy implements _ElementInjectorStrategy {
for (var i = 0; i < p.bindings.length; i++) { for (var i = 0; i < p.bindings.length; i++) {
if (p.bindings[i].key.token === query.selector) { if (p.bindings[i].key.token === query.selector) {
if (ist.objs[i] === undefinedValue) { if (ist.objs[i] === UNDEFINED) {
ist.objs[i] = ist.instantiateBinding(p.bindings[i], p.visibilities[i]); ist.objs[i] = ist.instantiateBinding(p.bindings[i], p.visibilities[i]);
} }
list.push(ist.objs[i]); list.push(ist.objs[i]);

View File

@ -36,7 +36,7 @@ export class Dependency {
const _EMPTY_LIST = CONST_EXPR([]); const _EMPTY_LIST = CONST_EXPR([]);
/** /**
* Describes how the {@link Injector} should instantiate a given token. * Describes how_ the {@link Injector} should instantiate a given token.
* *
* See {@link bind}. * See {@link bind}.
* *

View File

@ -16,7 +16,7 @@ import {SelfMetadata, HostMetadata, SkipSelfMetadata} from './metadata';
// Threshold for the dynamic version // Threshold for the dynamic version
const _MAX_CONSTRUCTION_COUNTER = 10; const _MAX_CONSTRUCTION_COUNTER = 10;
export const undefinedValue: Object = CONST_EXPR(new Object()); export const UNDEFINED: Object = CONST_EXPR(new Object());
export const PUBLIC: number = 1; export const PUBLIC: number = 1;
export const PRIVATE: number = 2; export const PRIVATE: number = 2;
@ -193,16 +193,16 @@ export interface InjectorStrategy {
} }
export class InjectorInlineStrategy implements InjectorStrategy { export class InjectorInlineStrategy implements InjectorStrategy {
obj0: any = undefinedValue; obj0: any = UNDEFINED;
obj1: any = undefinedValue; obj1: any = UNDEFINED;
obj2: any = undefinedValue; obj2: any = UNDEFINED;
obj3: any = undefinedValue; obj3: any = UNDEFINED;
obj4: any = undefinedValue; obj4: any = UNDEFINED;
obj5: any = undefinedValue; obj5: any = UNDEFINED;
obj6: any = undefinedValue; obj6: any = UNDEFINED;
obj7: any = undefinedValue; obj7: any = UNDEFINED;
obj8: any = undefinedValue; obj8: any = UNDEFINED;
obj9: any = undefinedValue; obj9: any = UNDEFINED;
constructor(public injector: Injector, public protoStrategy: ProtoInjectorInlineStrategy) {} constructor(public injector: Injector, public protoStrategy: ProtoInjectorInlineStrategy) {}
@ -223,67 +223,67 @@ export class InjectorInlineStrategy implements InjectorStrategy {
var inj = this.injector; var inj = this.injector;
if (p.keyId0 === keyId && (p.visibility0 & visibility) > 0) { if (p.keyId0 === keyId && (p.visibility0 & visibility) > 0) {
if (this.obj0 === undefinedValue) { if (this.obj0 === UNDEFINED) {
this.obj0 = inj._new(p.binding0, p.visibility0); this.obj0 = inj._new(p.binding0, p.visibility0);
} }
return this.obj0; return this.obj0;
} }
if (p.keyId1 === keyId && (p.visibility1 & visibility) > 0) { if (p.keyId1 === keyId && (p.visibility1 & visibility) > 0) {
if (this.obj1 === undefinedValue) { if (this.obj1 === UNDEFINED) {
this.obj1 = inj._new(p.binding1, p.visibility1); this.obj1 = inj._new(p.binding1, p.visibility1);
} }
return this.obj1; return this.obj1;
} }
if (p.keyId2 === keyId && (p.visibility2 & visibility) > 0) { if (p.keyId2 === keyId && (p.visibility2 & visibility) > 0) {
if (this.obj2 === undefinedValue) { if (this.obj2 === UNDEFINED) {
this.obj2 = inj._new(p.binding2, p.visibility2); this.obj2 = inj._new(p.binding2, p.visibility2);
} }
return this.obj2; return this.obj2;
} }
if (p.keyId3 === keyId && (p.visibility3 & visibility) > 0) { if (p.keyId3 === keyId && (p.visibility3 & visibility) > 0) {
if (this.obj3 === undefinedValue) { if (this.obj3 === UNDEFINED) {
this.obj3 = inj._new(p.binding3, p.visibility3); this.obj3 = inj._new(p.binding3, p.visibility3);
} }
return this.obj3; return this.obj3;
} }
if (p.keyId4 === keyId && (p.visibility4 & visibility) > 0) { if (p.keyId4 === keyId && (p.visibility4 & visibility) > 0) {
if (this.obj4 === undefinedValue) { if (this.obj4 === UNDEFINED) {
this.obj4 = inj._new(p.binding4, p.visibility4); this.obj4 = inj._new(p.binding4, p.visibility4);
} }
return this.obj4; return this.obj4;
} }
if (p.keyId5 === keyId && (p.visibility5 & visibility) > 0) { if (p.keyId5 === keyId && (p.visibility5 & visibility) > 0) {
if (this.obj5 === undefinedValue) { if (this.obj5 === UNDEFINED) {
this.obj5 = inj._new(p.binding5, p.visibility5); this.obj5 = inj._new(p.binding5, p.visibility5);
} }
return this.obj5; return this.obj5;
} }
if (p.keyId6 === keyId && (p.visibility6 & visibility) > 0) { if (p.keyId6 === keyId && (p.visibility6 & visibility) > 0) {
if (this.obj6 === undefinedValue) { if (this.obj6 === UNDEFINED) {
this.obj6 = inj._new(p.binding6, p.visibility6); this.obj6 = inj._new(p.binding6, p.visibility6);
} }
return this.obj6; return this.obj6;
} }
if (p.keyId7 === keyId && (p.visibility7 & visibility) > 0) { if (p.keyId7 === keyId && (p.visibility7 & visibility) > 0) {
if (this.obj7 === undefinedValue) { if (this.obj7 === UNDEFINED) {
this.obj7 = inj._new(p.binding7, p.visibility7); this.obj7 = inj._new(p.binding7, p.visibility7);
} }
return this.obj7; return this.obj7;
} }
if (p.keyId8 === keyId && (p.visibility8 & visibility) > 0) { if (p.keyId8 === keyId && (p.visibility8 & visibility) > 0) {
if (this.obj8 === undefinedValue) { if (this.obj8 === UNDEFINED) {
this.obj8 = inj._new(p.binding8, p.visibility8); this.obj8 = inj._new(p.binding8, p.visibility8);
} }
return this.obj8; return this.obj8;
} }
if (p.keyId9 === keyId && (p.visibility9 & visibility) > 0) { if (p.keyId9 === keyId && (p.visibility9 & visibility) > 0) {
if (this.obj9 === undefinedValue) { if (this.obj9 === UNDEFINED) {
this.obj9 = inj._new(p.binding9, p.visibility9); this.obj9 = inj._new(p.binding9, p.visibility9);
} }
return this.obj9; return this.obj9;
} }
return undefinedValue; return UNDEFINED;
} }
getObjAtIndex(index: number): any { getObjAtIndex(index: number): any {
@ -309,7 +309,7 @@ export class InjectorDynamicStrategy implements InjectorStrategy {
constructor(public protoStrategy: ProtoInjectorDynamicStrategy, public injector: Injector) { constructor(public protoStrategy: ProtoInjectorDynamicStrategy, public injector: Injector) {
this.objs = ListWrapper.createFixedSize(protoStrategy.bindings.length); this.objs = ListWrapper.createFixedSize(protoStrategy.bindings.length);
ListWrapper.fill(this.objs, undefinedValue); ListWrapper.fill(this.objs, UNDEFINED);
} }
resetConstructionCounter(): void { this.injector._constructionCounter = 0; } resetConstructionCounter(): void { this.injector._constructionCounter = 0; }
@ -329,7 +329,7 @@ export class InjectorDynamicStrategy implements InjectorStrategy {
for (var i = 0; i < p.keyIds.length; i++) { for (var i = 0; i < p.keyIds.length; i++) {
if (p.keyIds[i] === keyId && (p.visibilities[i] & visibility) > 0) { if (p.keyIds[i] === keyId && (p.visibilities[i] & visibility) > 0) {
if (this.objs[i] === undefinedValue) { if (this.objs[i] === UNDEFINED) {
this.objs[i] = this.injector._new(p.bindings[i], p.visibilities[i]); this.objs[i] = this.injector._new(p.bindings[i], p.visibilities[i]);
} }
@ -337,7 +337,7 @@ export class InjectorDynamicStrategy implements InjectorStrategy {
} }
} }
return undefinedValue; return UNDEFINED;
} }
getObjAtIndex(index: number): any { getObjAtIndex(index: number): any {
@ -693,8 +693,8 @@ export class Injector {
bindingVisibility: number): any { bindingVisibility: number): any {
var special = isPresent(this._depProvider) ? var special = isPresent(this._depProvider) ?
this._depProvider.getDependency(this, binding, dep) : this._depProvider.getDependency(this, binding, dep) :
undefinedValue; UNDEFINED;
if (special !== undefinedValue) { if (special !== UNDEFINED) {
return special; return special;
} else { } else {
return this._getByKey(dep.key, dep.lowerBoundVisibility, dep.upperBoundVisibility, return this._getByKey(dep.key, dep.lowerBoundVisibility, dep.upperBoundVisibility,
@ -729,7 +729,7 @@ export class Injector {
_getByKeySelf(key: Key, optional: boolean, bindingVisibility: number): any { _getByKeySelf(key: Key, optional: boolean, bindingVisibility: number): any {
var obj = this._strategy.getObjByKeyId(key.id, bindingVisibility); var obj = this._strategy.getObjByKeyId(key.id, bindingVisibility);
return (obj !== undefinedValue) ? obj : this._throwOrNull(key, optional); return (obj !== UNDEFINED) ? obj : this._throwOrNull(key, optional);
} }
_getByKeyHost(key: Key, optional: boolean, bindingVisibility: number, _getByKeyHost(key: Key, optional: boolean, bindingVisibility: number,
@ -746,7 +746,7 @@ export class Injector {
while (inj != null) { while (inj != null) {
var obj = inj._strategy.getObjByKeyId(key.id, bindingVisibility); var obj = inj._strategy.getObjByKeyId(key.id, bindingVisibility);
if (obj !== undefinedValue) return obj; if (obj !== UNDEFINED) return obj;
if (isPresent(inj._parent) && inj._isHost) { if (isPresent(inj._parent) && inj._isHost) {
return this._getPrivateDependency(key, optional, inj); return this._getPrivateDependency(key, optional, inj);
@ -760,7 +760,7 @@ export class Injector {
_getPrivateDependency(key: Key, optional: boolean, inj: Injector): any { _getPrivateDependency(key: Key, optional: boolean, inj: Injector): any {
var obj = inj._parent._strategy.getObjByKeyId(key.id, PRIVATE); var obj = inj._parent._strategy.getObjByKeyId(key.id, PRIVATE);
return (obj !== undefinedValue) ? obj : this._throwOrNull(key, optional); return (obj !== UNDEFINED) ? obj : this._throwOrNull(key, optional);
} }
_getByKeyDefault(key: Key, optional: boolean, bindingVisibility: number, _getByKeyDefault(key: Key, optional: boolean, bindingVisibility: number,
@ -774,7 +774,7 @@ export class Injector {
while (inj != null) { while (inj != null) {
var obj = inj._strategy.getObjByKeyId(key.id, bindingVisibility); var obj = inj._strategy.getObjByKeyId(key.id, bindingVisibility);
if (obj !== undefinedValue) return obj; if (obj !== UNDEFINED) return obj;
bindingVisibility = inj._isHost ? PUBLIC_AND_PRIVATE : PUBLIC; bindingVisibility = inj._isHost ? PUBLIC_AND_PRIVATE : PUBLIC;
inj = inj._parent; inj = inj._parent;

View File

@ -35,7 +35,7 @@ export {NgValidator, NgRequiredValidator} from './directives/validators';
* *
* This is a shorthand for importing them each individually. * This is a shorthand for importing them each individually.
*/ */
export const formDirectives: List<Type> = CONST_EXPR([ export const FORM_DIRECTIVES: List<Type> = CONST_EXPR([
NgControlName, NgControlName,
NgControlGroup, NgControlGroup,

View File

@ -24,7 +24,7 @@ const controlGroupBinding =
* ``` * ```
* @Component({selector: "signup-comp"}) * @Component({selector: "signup-comp"})
* @View({ * @View({
* directives: [formDirectives], * directives: [FORM_DIRECTIVES],
* template: ` * template: `
* <form #f="form" (submit)='onSignUp(f.value)'> * <form #f="form" (submit)='onSignUp(f.value)'>
* <div ng-control-group='credentials' #credentials="form"> * <div ng-control-group='credentials' #credentials="form">

View File

@ -29,7 +29,7 @@ const controlNameBinding =
* ``` * ```
* @Component({selector: "login-comp"}) * @Component({selector: "login-comp"})
* @View({ * @View({
* directives: [formDirectives], * directives: [FORM_DIRECTIVES],
* template: ` * template: `
* <form #f="form" (submit)='onLogIn(f.value)'> * <form #f="form" (submit)='onLogIn(f.value)'>
* Login <input type='text' ng-control='login' #l="form"> * Login <input type='text' ng-control='login' #l="form">
@ -52,7 +52,7 @@ const controlNameBinding =
* ``` * ```
* @Component({selector: "login-comp"}) * @Component({selector: "login-comp"})
* @View({ * @View({
* directives: [formDirectives], * directives: [FORM_DIRECTIVES],
* template: ` * template: `
* <form (submit)='onLogIn()'> * <form (submit)='onLogIn()'>
* Login <input type='text' ng-control='login' [(ng-model)]="credentials.login"> * Login <input type='text' ng-control='login' [(ng-model)]="credentials.login">

View File

@ -26,7 +26,7 @@ const formDirectiveBinding =
* ``` * ```
* @Component({selector: "signup-comp"}) * @Component({selector: "signup-comp"})
* @View({ * @View({
* directives: [formDirectives], * directives: [FORM_DIRECTIVES],
* template: ` * template: `
* <form #f="form" (submit)='onSignUp(f.value)'> * <form #f="form" (submit)='onSignUp(f.value)'>
* <div ng-control-group='credentials' #credentials="form"> * <div ng-control-group='credentials' #credentials="form">

View File

@ -27,7 +27,7 @@ const formControlBinding =
* ``` * ```
* @Component({selector: "login-comp"}) * @Component({selector: "login-comp"})
* @View({ * @View({
* directives: [formDirectives], * directives: [FORM_DIRECTIVES],
* template: "<input type='text' [ng-form-control]='loginControl'>" * template: "<input type='text' [ng-form-control]='loginControl'>"
* }) * })
* class LoginComp { * class LoginComp {
@ -45,7 +45,7 @@ const formControlBinding =
* ``` * ```
* @Component({selector: "login-comp"}) * @Component({selector: "login-comp"})
* @View({ * @View({
* directives: [formDirectives], * directives: [FORM_DIRECTIVES],
* template: "<input type='text' [ng-form-control]='loginControl' [(ng-model)]='login'>" * template: "<input type='text' [ng-form-control]='loginControl' [(ng-model)]='login'>"
* }) * })
* class LoginComp { * class LoginComp {

View File

@ -26,7 +26,7 @@ const formDirectiveBinding =
* ``` * ```
* @Component({selector: "login-comp"}) * @Component({selector: "login-comp"})
* @View({ * @View({
* directives: [formDirectives], * directives: [FORM_DIRECTIVES],
* template: "<form [ng-form-model]='loginForm'>" + * template: "<form [ng-form-model]='loginForm'>" +
* "Login <input type='text' ng-control='login'>" + * "Login <input type='text' ng-control='login'>" +
* "Password <input type='password' ng-control='password'>" + * "Password <input type='password' ng-control='password'>" +
@ -55,7 +55,7 @@ const formDirectiveBinding =
* ``` * ```
* @Component({selector: "login-comp"}) * @Component({selector: "login-comp"})
* @View({ * @View({
* directives: [formDirectives], * directives: [FORM_DIRECTIVES],
* template: "<form [ng-form-model]='loginForm'>" + * template: "<form [ng-form-model]='loginForm'>" +
* "Login <input type='text' ng-control='login' [(ng-model)]='login'>" + * "Login <input type='text' ng-control='login' [(ng-model)]='login'>" +
* "Password <input type='password' ng-control='password' [(ng-model)]='password'>" + * "Password <input type='password' ng-control='password' [(ng-model)]='password'>" +

View File

@ -19,7 +19,7 @@ const formControlBinding = CONST_EXPR(new Binding(NgControl, {toAlias: forwardRe
* ``` * ```
* @Component({selector: "search-comp"}) * @Component({selector: "search-comp"})
* @View({ * @View({
* directives: [formDirectives], * directives: [FORM_DIRECTIVES],
* template: ` * template: `
<input type='text' [(ng-model)]="searchQuery"> <input type='text' [(ng-model)]="searchQuery">
* `}) * `})

View File

@ -11,7 +11,7 @@ import * as modelModule from './model';
* *
* ``` * ```
* import {Component, View, bootstrap} from 'angular2/angular2'; * import {Component, View, bootstrap} from 'angular2/angular2';
* import {FormBuilder, Validators, formDirectives, ControlGroup} from 'angular2/forms'; * import {FormBuilder, Validators, FORM_DIRECTIVES, ControlGroup} from 'angular2/forms';
* *
* @Component({ * @Component({
* selector: 'login-comp', * selector: 'login-comp',
@ -31,7 +31,7 @@ import * as modelModule from './model';
* </form> * </form>
* `, * `,
* directives: [ * directives: [
* formDirectives * FORM_DIRECTIVES
* ] * ]
* }) * })
* class LoginComp { * class LoginComp {

View File

@ -21,7 +21,7 @@ import {ElementSchemaRegistry} from '../schema/element_schema_registry';
import {Parser} from 'angular2/src/change_detection/change_detection'; import {Parser} from 'angular2/src/change_detection/change_detection';
import * as pvm from '../view/proto_view_merger'; import * as pvm from '../view/proto_view_merger';
import {CssSelector} from './selector'; import {CssSelector} from './selector';
import {DOCUMENT_TOKEN, APP_ID_TOKEN} from '../dom_tokens'; import {DOCUMENT, APP_ID} from '../dom_tokens';
import {Inject} from 'angular2/di'; import {Inject} from 'angular2/di';
import {SharedStylesHost} from '../view/shared_styles_host'; import {SharedStylesHost} from '../view/shared_styles_host';
import {prependAll} from '../util'; import {prependAll} from '../util';
@ -126,7 +126,7 @@ export class DomCompiler extends RenderCompiler {
export class DefaultDomCompiler extends DomCompiler { export class DefaultDomCompiler extends DomCompiler {
constructor(schemaRegistry: ElementSchemaRegistry, templateCloner: TemplateCloner, parser: Parser, constructor(schemaRegistry: ElementSchemaRegistry, templateCloner: TemplateCloner, parser: Parser,
viewLoader: ViewLoader, sharedStylesHost: SharedStylesHost, viewLoader: ViewLoader, sharedStylesHost: SharedStylesHost,
@Inject(APP_ID_TOKEN) appId: any) { @Inject(APP_ID) appId: any) {
super(schemaRegistry, templateCloner, new DefaultStepFactory(parser, appId), viewLoader, super(schemaRegistry, templateCloner, new DefaultStepFactory(parser, appId), viewLoader,
sharedStylesHost); sharedStylesHost);
} }

View File

@ -35,7 +35,7 @@ import {
import {TemplateCloner} from './template_cloner'; import {TemplateCloner} from './template_cloner';
import {DOCUMENT_TOKEN, DOM_REFLECT_PROPERTIES_AS_ATTRIBUTES} from './dom_tokens'; import {DOCUMENT, DOM_REFLECT_PROPERTIES_AS_ATTRIBUTES} from './dom_tokens';
const REFLECT_PREFIX: string = 'ng-reflect-'; const REFLECT_PREFIX: string = 'ng-reflect-';
@ -47,7 +47,7 @@ export class DomRenderer extends Renderer {
constructor(private _eventManager: EventManager, constructor(private _eventManager: EventManager,
private _domSharedStylesHost: DomSharedStylesHost, private _domSharedStylesHost: DomSharedStylesHost,
private _templateCloner: TemplateCloner, @Inject(DOCUMENT_TOKEN) document, private _templateCloner: TemplateCloner, @Inject(DOCUMENT) document,
@Inject(DOM_REFLECT_PROPERTIES_AS_ATTRIBUTES) reflectPropertiesAsAttributes: @Inject(DOM_REFLECT_PROPERTIES_AS_ATTRIBUTES) reflectPropertiesAsAttributes:
boolean) { boolean) {
super(); super();

View File

@ -1,7 +1,7 @@
import {OpaqueToken, bind, Binding} from 'angular2/di'; import {OpaqueToken, Binding} from 'angular2/di';
import {CONST_EXPR, StringWrapper, Math} from 'angular2/src/facade/lang'; import {CONST_EXPR, StringWrapper, Math} from 'angular2/src/facade/lang';
export const DOCUMENT_TOKEN: OpaqueToken = CONST_EXPR(new OpaqueToken('DocumentToken')); export const DOCUMENT: OpaqueToken = CONST_EXPR(new OpaqueToken('DocumentToken'));
export const DOM_REFLECT_PROPERTIES_AS_ATTRIBUTES: OpaqueToken = export const DOM_REFLECT_PROPERTIES_AS_ATTRIBUTES: OpaqueToken =
CONST_EXPR(new OpaqueToken('DomReflectPropertiesAsAttributes')); CONST_EXPR(new OpaqueToken('DomReflectPropertiesAsAttributes'));
@ -10,19 +10,23 @@ export const DOM_REFLECT_PROPERTIES_AS_ATTRIBUTES: OpaqueToken =
/** /**
* A unique id (string) for an angular application. * A unique id (string) for an angular application.
*/ */
export const APP_ID_TOKEN: OpaqueToken = CONST_EXPR(new OpaqueToken('AppId')); export const APP_ID: OpaqueToken = CONST_EXPR(new OpaqueToken('AppId'));
function _appIdRandomBindingFactory() {
return `${randomChar()}${randomChar()}${randomChar()}`;
}
/** /**
* Bindings that will generate a random APP_ID_TOKEN. * Bindings that will generate a random APP_ID_TOKEN.
*/ */
export var APP_ID_RANDOM_BINDING: Binding = export const APP_ID_RANDOM_BINDING: Binding =
bind(APP_ID_TOKEN).toFactory(() => `${randomChar()}${randomChar()}${randomChar()}`, []); CONST_EXPR(new Binding(APP_ID, {toFactory: _appIdRandomBindingFactory, deps: []}));
/** /**
* Defines when a compiled template should be stored as a string * Defines when a compiled template should be stored as a string
* rather than keeping its Nodes to preserve memory. * rather than keeping its Nodes to preserve memory.
*/ */
export const MAX_IN_MEMORY_ELEMENTS_PER_TEMPLATE_TOKEN: OpaqueToken = export const MAX_IN_MEMORY_ELEMENTS_PER_TEMPLATE: OpaqueToken =
CONST_EXPR(new OpaqueToken('MaxInMemoryElementsPerTemplate')); CONST_EXPR(new OpaqueToken('MaxInMemoryElementsPerTemplate'));
function randomChar(): string { function randomChar(): string {

View File

@ -1,13 +1,13 @@
import {isString} from 'angular2/src/facade/lang'; import {isString} from 'angular2/src/facade/lang';
import {Injectable, Inject} from 'angular2/di'; import {Injectable, Inject} from 'angular2/di';
import {DOM} from 'angular2/src/dom/dom_adapter'; import {DOM} from 'angular2/src/dom/dom_adapter';
import {MAX_IN_MEMORY_ELEMENTS_PER_TEMPLATE_TOKEN} from './dom_tokens'; import {MAX_IN_MEMORY_ELEMENTS_PER_TEMPLATE} from './dom_tokens';
@Injectable() @Injectable()
export class TemplateCloner { export class TemplateCloner {
maxInMemoryElementsPerTemplate: number; maxInMemoryElementsPerTemplate: number;
constructor(@Inject(MAX_IN_MEMORY_ELEMENTS_PER_TEMPLATE_TOKEN) maxInMemoryElementsPerTemplate) { constructor(@Inject(MAX_IN_MEMORY_ELEMENTS_PER_TEMPLATE) maxInMemoryElementsPerTemplate) {
this.maxInMemoryElementsPerTemplate = maxInMemoryElementsPerTemplate; this.maxInMemoryElementsPerTemplate = maxInMemoryElementsPerTemplate;
} }

View File

@ -1,7 +1,7 @@
import {DOM} from 'angular2/src/dom/dom_adapter'; import {DOM} from 'angular2/src/dom/dom_adapter';
import {Inject, Injectable} from 'angular2/di'; import {Inject, Injectable} from 'angular2/di';
import {SetWrapper} from 'angular2/src/facade/collection'; import {SetWrapper} from 'angular2/src/facade/collection';
import {DOCUMENT_TOKEN} from '../dom_tokens'; import {DOCUMENT} from '../dom_tokens';
@Injectable() @Injectable()
export class SharedStylesHost { export class SharedStylesHost {
@ -30,7 +30,7 @@ export class SharedStylesHost {
@Injectable() @Injectable()
export class DomSharedStylesHost extends SharedStylesHost { export class DomSharedStylesHost extends SharedStylesHost {
private _hostNodes: Set<Node> = new Set(); private _hostNodes: Set<Node> = new Set();
constructor(@Inject(DOCUMENT_TOKEN) doc: any) { constructor(@Inject(DOCUMENT) doc: any) {
super(); super();
this._hostNodes.add(doc.head); this._hostNodes.add(doc.head);
} }

View File

@ -4,7 +4,7 @@ import {EventEmitter, ObservableWrapper} from 'angular2/src/facade/async';
import {BaseException, isBlank} from 'angular2/src/facade/lang'; import {BaseException, isBlank} from 'angular2/src/facade/lang';
import {OpaqueToken, Injectable, Optional, Inject} from 'angular2/di'; import {OpaqueToken, Injectable, Optional, Inject} from 'angular2/di';
export const appBaseHrefToken: OpaqueToken = CONST_EXPR(new OpaqueToken('locationHrefToken')); export const APP_BASE_HREF: OpaqueToken = CONST_EXPR(new OpaqueToken('appBaseHref'));
/** /**
* This is the service that an application developer will directly interact with. * This is the service that an application developer will directly interact with.
@ -22,7 +22,7 @@ export class Location {
private _baseHref: string; private _baseHref: string;
constructor(public _platformStrategy: LocationStrategy, constructor(public _platformStrategy: LocationStrategy,
@Optional() @Inject(appBaseHrefToken) href?: string) { @Optional() @Inject(APP_BASE_HREF) href?: string) {
var browserBaseHref = isPresent(href) ? href : this._platformStrategy.getBaseHref(); var browserBaseHref = isPresent(href) ? href : this._platformStrategy.getBaseHref();
if (isBlank(browserBaseHref)) { if (isBlank(browserBaseHref)) {

View File

@ -4,7 +4,7 @@ import {isBlank, isPresent} from 'angular2/src/facade/lang';
import {Directive, Attribute} from 'angular2/src/core/annotations/decorators'; import {Directive, Attribute} from 'angular2/src/core/annotations/decorators';
import {DynamicComponentLoader, ComponentRef, ElementRef} from 'angular2/core'; import {DynamicComponentLoader, ComponentRef, ElementRef} from 'angular2/core';
import {Injector, bind, Dependency, undefinedValue} from 'angular2/di'; import {Injector, bind, Dependency, UNDEFINED} from 'angular2/di';
import * as routerMod from './router'; import * as routerMod from './router';
import {Instruction, ComponentInstruction, RouteParams} from './instruction'; import {Instruction, ComponentInstruction, RouteParams} from './instruction';

View File

@ -16,7 +16,7 @@ import {
import {el} from './utils'; import {el} from './utils';
import {DOCUMENT_TOKEN} from 'angular2/src/render/render'; import {DOCUMENT} from 'angular2/src/render/render';
import {DOM} from 'angular2/src/dom/dom_adapter'; import {DOM} from 'angular2/src/dom/dom_adapter';
import {DebugElement} from 'angular2/src/debug/debug_element'; import {DebugElement} from 'angular2/src/debug/debug_element';
@ -135,7 +135,7 @@ export class TestComponentBuilder {
var rootElId = `root${_nextRootElementId++}`; var rootElId = `root${_nextRootElementId++}`;
var rootEl = el(`<div id="${rootElId}"></div>`); var rootEl = el(`<div id="${rootElId}"></div>`);
var doc = this._injector.get(DOCUMENT_TOKEN); var doc = this._injector.get(DOCUMENT);
// TODO(juliemr): can/should this be optional? // TODO(juliemr): can/should this be optional?
var oldRoots = DOM.querySelectorAll(doc, '[id^=root]'); var oldRoots = DOM.querySelectorAll(doc, '[id^=root]');

View File

@ -53,13 +53,13 @@ import {ProtoViewFactory} from 'angular2/src/core/compiler/proto_view_factory';
import {RenderCompiler, Renderer} from 'angular2/src/render/api'; import {RenderCompiler, Renderer} from 'angular2/src/render/api';
import { import {
DomRenderer, DomRenderer,
DOCUMENT_TOKEN, DOCUMENT,
DOM_REFLECT_PROPERTIES_AS_ATTRIBUTES, DOM_REFLECT_PROPERTIES_AS_ATTRIBUTES,
DefaultDomCompiler, DefaultDomCompiler,
APP_ID_TOKEN, APP_ID,
SharedStylesHost, SharedStylesHost,
DomSharedStylesHost, DomSharedStylesHost,
MAX_IN_MEMORY_ELEMENTS_PER_TEMPLATE_TOKEN, MAX_IN_MEMORY_ELEMENTS_PER_TEMPLATE,
TemplateCloner TemplateCloner
} from 'angular2/src/render/render'; } from 'angular2/src/render/render';
import {ElementSchemaRegistry} from 'angular2/src/render/dom/schema/element_schema_registry'; import {ElementSchemaRegistry} from 'angular2/src/render/dom/schema/element_schema_registry';
@ -99,13 +99,13 @@ function _getAppBindings() {
} }
return [ return [
bind(DOCUMENT_TOKEN) bind(DOCUMENT)
.toValue(appDoc), .toValue(appDoc),
DomRenderer, DomRenderer,
bind(Renderer).toAlias(DomRenderer), bind(Renderer).toAlias(DomRenderer),
bind(APP_ID_TOKEN).toValue('a'), bind(APP_ID).toValue('a'),
TemplateCloner, TemplateCloner,
bind(MAX_IN_MEMORY_ELEMENTS_PER_TEMPLATE_TOKEN).toValue(-1), bind(MAX_IN_MEMORY_ELEMENTS_PER_TEMPLATE).toValue(-1),
DefaultDomCompiler, DefaultDomCompiler,
bind(RenderCompiler).toAlias(DefaultDomCompiler), bind(RenderCompiler).toAlias(DefaultDomCompiler),
bind(ElementSchemaRegistry).toValue(new DomElementSchemaRegistry()), bind(ElementSchemaRegistry).toValue(new DomElementSchemaRegistry()),

View File

@ -23,11 +23,11 @@ import {Renderer, RenderCompiler} from 'angular2/src/render/api';
import {AppRootUrl} from 'angular2/src/services/app_root_url'; import {AppRootUrl} from 'angular2/src/services/app_root_url';
import { import {
DomRenderer, DomRenderer,
DOCUMENT_TOKEN, DOCUMENT,
DOM_REFLECT_PROPERTIES_AS_ATTRIBUTES, DOM_REFLECT_PROPERTIES_AS_ATTRIBUTES,
DefaultDomCompiler, DefaultDomCompiler,
APP_ID_RANDOM_BINDING, APP_ID_RANDOM_BINDING,
MAX_IN_MEMORY_ELEMENTS_PER_TEMPLATE_TOKEN, MAX_IN_MEMORY_ELEMENTS_PER_TEMPLATE,
TemplateCloner TemplateCloner
} from 'angular2/src/render/render'; } from 'angular2/src/render/render';
import {ElementSchemaRegistry} from 'angular2/src/render/dom/schema/element_schema_registry'; import {ElementSchemaRegistry} from 'angular2/src/render/dom/schema/element_schema_registry';
@ -79,7 +79,7 @@ function _injectorBindings(): List<Type | Binding | List<any>> {
} }
return [ return [
bind(DOCUMENT_TOKEN) bind(DOCUMENT)
.toValue(DOM.defaultDoc()), .toValue(DOM.defaultDoc()),
bind(EventManager) bind(EventManager)
.toFactory( .toFactory(
@ -94,7 +94,7 @@ function _injectorBindings(): List<Type | Binding | List<any>> {
bind(Renderer).toAlias(DomRenderer), bind(Renderer).toAlias(DomRenderer),
APP_ID_RANDOM_BINDING, APP_ID_RANDOM_BINDING,
TemplateCloner, TemplateCloner,
bind(MAX_IN_MEMORY_ELEMENTS_PER_TEMPLATE_TOKEN).toValue(20), bind(MAX_IN_MEMORY_ELEMENTS_PER_TEMPLATE).toValue(20),
DefaultDomCompiler, DefaultDomCompiler,
bind(RenderCompiler).toAlias(DefaultDomCompiler), bind(RenderCompiler).toAlias(DefaultDomCompiler),
DomSharedStylesHost, DomSharedStylesHost,

View File

@ -54,10 +54,7 @@ import {internalView} from 'angular2/src/core/compiler/view_ref';
import {MessageBroker} from 'angular2/src/web-workers/worker/broker'; import {MessageBroker} from 'angular2/src/web-workers/worker/broker';
import {WebWorkerMessageBus} from 'angular2/src/web-workers/worker/application'; import {WebWorkerMessageBus} from 'angular2/src/web-workers/worker/application';
import { import {APP_COMPONENT_REF_PROMISE, APP_COMPONENT} from 'angular2/src/core/application_tokens';
appComponentRefPromiseToken,
appComponentTypeToken
} from 'angular2/src/core/application_tokens';
import {ApplicationRef} from 'angular2/src/core/application'; import {ApplicationRef} from 'angular2/src/core/application';
import {createNgZone} from 'angular2/src/core/application_common'; import {createNgZone} from 'angular2/src/core/application_common';
import {Serializer} from "angular2/src/web-workers/shared/serializer"; import {Serializer} from "angular2/src/web-workers/shared/serializer";
@ -87,9 +84,9 @@ function _injectorBindings(appComponentType, bus: WebWorkerMessageBus,
bestChangeDetection = JitChangeDetection; bestChangeDetection = JitChangeDetection;
} }
return [ return [
bind(appComponentTypeToken) bind(APP_COMPONENT)
.toValue(appComponentType), .toValue(appComponentType),
bind(appComponentRefPromiseToken) bind(APP_COMPONENT_REF_PROMISE)
.toFactory( .toFactory(
(dynamicComponentLoader, injector) => { (dynamicComponentLoader, injector) => {
@ -99,7 +96,7 @@ function _injectorBindings(appComponentType, bus: WebWorkerMessageBus,
}, },
[DynamicComponentLoader, Injector]), [DynamicComponentLoader, Injector]),
bind(appComponentType).toFactory((ref) => ref.instance, [appComponentRefPromiseToken]), bind(appComponentType).toFactory((ref) => ref.instance, [APP_COMPONENT_REF_PROMISE]),
bind(LifeCycle).toFactory((exceptionHandler) => new LifeCycle(null, assertionsEnabled()), bind(LifeCycle).toFactory((exceptionHandler) => new LifeCycle(null, assertionsEnabled()),
[ExceptionHandler]), [ExceptionHandler]),
Serializer, Serializer,
@ -163,7 +160,7 @@ export function bootstrapWebWorkerCommon(
message["data"]["value"]); message["data"]["value"]);
var compRefToken = PromiseWrapper.wrap(() => { var compRefToken = PromiseWrapper.wrap(() => {
try { try {
return appInjector.get(appComponentRefPromiseToken); return appInjector.get(APP_COMPONENT_REF_PROMISE);
} catch (e) { } catch (e) {
throw e; throw e;
} }

View File

@ -20,7 +20,7 @@ import {bind, Inject, Injector} from 'angular2/di';
import {LifeCycle} from 'angular2/core'; import {LifeCycle} from 'angular2/core';
import {ExceptionHandler} from 'angular2/src/core/exception_handler'; import {ExceptionHandler} from 'angular2/src/core/exception_handler';
import {Testability, TestabilityRegistry} from 'angular2/src/core/testability/testability'; import {Testability, TestabilityRegistry} from 'angular2/src/core/testability/testability';
import {DOCUMENT_TOKEN} from 'angular2/src/render/render'; import {DOCUMENT} from 'angular2/src/render/render';
@Component({selector: 'hello-app'}) @Component({selector: 'hello-app'})
@View({template: '{{greeting}} world!'}) @View({template: '{{greeting}} world!'})
@ -87,7 +87,7 @@ export function main() {
DOM.appendChild(fakeDoc.body, el2); DOM.appendChild(fakeDoc.body, el2);
DOM.appendChild(el, lightDom); DOM.appendChild(el, lightDom);
DOM.setText(lightDom, 'loading'); DOM.setText(lightDom, 'loading');
testBindings = [bind(DOCUMENT_TOKEN).toValue(fakeDoc)]; testBindings = [bind(DOCUMENT).toValue(fakeDoc)];
}); });
it('should throw if bootstrapped Directive is not a Component', it('should throw if bootstrapped Directive is not a Component',

View File

@ -24,7 +24,7 @@ import {Component, View, LifecycleEvent} from 'angular2/annotations';
import * as viewAnn from 'angular2/src/core/annotations_impl/view'; import * as viewAnn from 'angular2/src/core/annotations_impl/view';
import {DynamicComponentLoader} from 'angular2/src/core/compiler/dynamic_component_loader'; import {DynamicComponentLoader} from 'angular2/src/core/compiler/dynamic_component_loader';
import {ElementRef} from 'angular2/src/core/compiler/element_ref'; import {ElementRef} from 'angular2/src/core/compiler/element_ref';
import {DOCUMENT_TOKEN} from 'angular2/src/render/render'; import {DOCUMENT} from 'angular2/src/render/render';
import {DOM} from 'angular2/src/dom/dom_adapter'; import {DOM} from 'angular2/src/dom/dom_adapter';
export function main() { export function main() {
@ -218,7 +218,7 @@ export function main() {
describe('loadAsRoot', () => { describe('loadAsRoot', () => {
it('should allow to create, update and destroy components', it('should allow to create, update and destroy components',
inject([AsyncTestCompleter, DynamicComponentLoader, DOCUMENT_TOKEN, Injector], inject([AsyncTestCompleter, DynamicComponentLoader, DOCUMENT, Injector],
(async, loader, doc, injector) => { (async, loader, doc, injector) => {
var rootEl = el('<child-cmp></child-cmp>'); var rootEl = el('<child-cmp></child-cmp>');
DOM.appendChild(doc.body, rootEl); DOM.appendChild(doc.body, rootEl);

View File

@ -38,7 +38,7 @@ import {
ViewEncapsulation ViewEncapsulation
} from 'angular2/angular2'; } from 'angular2/angular2';
import {MAX_IN_MEMORY_ELEMENTS_PER_TEMPLATE_TOKEN} from 'angular2/src/render/render'; import {MAX_IN_MEMORY_ELEMENTS_PER_TEMPLATE} from 'angular2/src/render/render';
export function main() { export function main() {
describe('projection', () => { describe('projection', () => {
@ -445,12 +445,12 @@ export function main() {
} }
describe('serialize templates', () => { describe('serialize templates', () => {
beforeEachBindings(() => [bind(MAX_IN_MEMORY_ELEMENTS_PER_TEMPLATE_TOKEN).toValue(0)]); beforeEachBindings(() => [bind(MAX_IN_MEMORY_ELEMENTS_PER_TEMPLATE).toValue(0)]);
runTests(); runTests();
}); });
describe("don't serialize templates", () => { describe("don't serialize templates", () => {
beforeEachBindings(() => [bind(MAX_IN_MEMORY_ELEMENTS_PER_TEMPLATE_TOKEN).toValue(-1)]); beforeEachBindings(() => [bind(MAX_IN_MEMORY_ELEMENTS_PER_TEMPLATE).toValue(-1)]);
runTests(); runTests();
}); });

View File

@ -24,7 +24,7 @@ import {
Control, Control,
ControlGroup, ControlGroup,
NgForm, NgForm,
formDirectives, FORM_DIRECTIVES,
Validators, Validators,
NgControl, NgControl,
ControlValueAccessor ControlValueAccessor
@ -770,7 +770,7 @@ class WrappedValue implements ControlValueAccessor {
} }
@Component({selector: "my-comp"}) @Component({selector: "my-comp"})
@View({directives: [formDirectives, WrappedValue, NgIf, NgFor]}) @View({directives: [FORM_DIRECTIVES, WrappedValue, NgIf, NgFor]})
class MyComp { class MyComp {
form: any; form: any;
name: string; name: string;

View File

@ -5,7 +5,7 @@ import {PromiseWrapper, Promise} from 'angular2/src/facade/async';
import {DOM} from 'angular2/src/dom/dom_adapter'; import {DOM} from 'angular2/src/dom/dom_adapter';
import {DomRenderer} from 'angular2/src/render/dom/dom_renderer'; import {DomRenderer} from 'angular2/src/render/dom/dom_renderer';
import {DOCUMENT_TOKEN} from 'angular2/src/render/dom/dom_tokens'; import {DOCUMENT} from 'angular2/src/render/dom/dom_tokens';
import {DefaultDomCompiler} from 'angular2/src/render/dom/compiler/compiler'; import {DefaultDomCompiler} from 'angular2/src/render/dom/compiler/compiler';
import { import {
RenderViewWithFragments, RenderViewWithFragments,
@ -65,8 +65,7 @@ export class DomTestbed {
compiler: DefaultDomCompiler; compiler: DefaultDomCompiler;
rootEl; rootEl;
constructor(renderer: DomRenderer, compiler: DefaultDomCompiler, constructor(renderer: DomRenderer, compiler: DefaultDomCompiler, @Inject(DOCUMENT) document) {
@Inject(DOCUMENT_TOKEN) document) {
this.renderer = renderer; this.renderer = renderer;
this.compiler = compiler; this.compiler = compiler;
this.rootEl = el('<div id="root" class="rootElem"></div>'); this.rootEl = el('<div id="root" class="rootElem"></div>');

View File

@ -14,7 +14,7 @@ import {
import {Injector, bind} from 'angular2/di'; import {Injector, bind} from 'angular2/di';
import {CONST_EXPR} from 'angular2/src/facade/lang'; import {CONST_EXPR} from 'angular2/src/facade/lang';
import {Location, appBaseHrefToken} from 'angular2/src/router/location'; import {Location, APP_BASE_HREF} from 'angular2/src/router/location';
import {LocationStrategy} from 'angular2/src/router/location_strategy'; import {LocationStrategy} from 'angular2/src/router/location_strategy';
import {MockLocationStrategy} from 'angular2/src/mock/mock_location_strategy'; import {MockLocationStrategy} from 'angular2/src/mock/mock_location_strategy';
@ -71,7 +71,7 @@ export function main() {
}); });
it('should use optional base href param', () => { it('should use optional base href param', () => {
let location = makeLocation('/', bind(appBaseHrefToken).toValue('/my/custom/href')); let location = makeLocation('/', bind(APP_BASE_HREF).toValue('/my/custom/href'));
location.go('user/btford'); location.go('user/btford');
expect(locationStrategy.path()).toEqual('/my/custom/href/user/btford'); expect(locationStrategy.path()).toEqual('/my/custom/href/user/btford');
}); });

View File

@ -15,14 +15,14 @@ import {bootstrap} from 'angular2/bootstrap';
import {Component, Directive, View} from 'angular2/annotations'; import {Component, Directive, View} from 'angular2/annotations';
import {DOM} from 'angular2/src/dom/dom_adapter'; import {DOM} from 'angular2/src/dom/dom_adapter';
import {bind} from 'angular2/di'; import {bind} from 'angular2/di';
import {DOCUMENT_TOKEN} from 'angular2/src/render/render'; import {DOCUMENT} from 'angular2/src/render/render';
import {Type} from 'angular2/src/facade/lang'; import {Type} from 'angular2/src/facade/lang';
import { import {
routerInjectables, routerInjectables,
Router, Router,
RouteConfig, RouteConfig,
appBaseHrefToken, APP_BASE_HREF,
routerDirectives routerDirectives
} from 'angular2/router'; } from 'angular2/router';
@ -49,7 +49,7 @@ export function main() {
testBindings = [ testBindings = [
routerInjectables, routerInjectables,
bind(LocationStrategy).toClass(MockLocationStrategy), bind(LocationStrategy).toClass(MockLocationStrategy),
bind(DOCUMENT_TOKEN).toValue(fakeDoc), bind(DOCUMENT).toValue(fakeDoc),
bind(ExceptionHandler).toValue(exceptionHandler) bind(ExceptionHandler).toValue(exceptionHandler)
]; ];
}); });

View File

@ -18,7 +18,7 @@ import {bootstrap} from 'angular2/src/core/application';
import {Component, Directive, View} from 'angular2/src/core/annotations/decorators'; import {Component, Directive, View} from 'angular2/src/core/annotations/decorators';
import {DOM} from 'angular2/src/dom/dom_adapter'; import {DOM} from 'angular2/src/dom/dom_adapter';
import {bind} from 'angular2/di'; import {bind} from 'angular2/di';
import {DOCUMENT_TOKEN} from 'angular2/src/render/render'; import {DOCUMENT} from 'angular2/src/render/render';
import {RouteConfig, Route, Redirect} from 'angular2/src/router/route_config_decorator'; import {RouteConfig, Route, Redirect} from 'angular2/src/router/route_config_decorator';
import {PromiseWrapper} from 'angular2/src/facade/async'; import {PromiseWrapper} from 'angular2/src/facade/async';
import {BaseException} from 'angular2/src/facade/lang'; import {BaseException} from 'angular2/src/facade/lang';
@ -26,14 +26,14 @@ import {
routerInjectables, routerInjectables,
RouteParams, RouteParams,
Router, Router,
appBaseHrefToken, APP_BASE_HREF,
routerDirectives, routerDirectives,
HashLocationStrategy HashLocationStrategy
} from 'angular2/router'; } from 'angular2/router';
import {LocationStrategy} from 'angular2/src/router/location_strategy'; import {LocationStrategy} from 'angular2/src/router/location_strategy';
import {MockLocationStrategy} from 'angular2/src/mock/mock_location_strategy'; import {MockLocationStrategy} from 'angular2/src/mock/mock_location_strategy';
import {appComponentTypeToken} from 'angular2/src/core/application_tokens'; import {APP_COMPONENT} from 'angular2/src/core/application_tokens';
export function main() { export function main() {
describe('router injectables', () => { describe('router injectables', () => {
@ -53,7 +53,7 @@ export function main() {
[ [
routerInjectables, routerInjectables,
bind(LocationStrategy).toClass(MockLocationStrategy), bind(LocationStrategy).toClass(MockLocationStrategy),
bind(DOCUMENT_TOKEN).toValue(fakeDoc) bind(DOCUMENT).toValue(fakeDoc)
]) ])
.then((applicationRef) => { .then((applicationRef) => {
var router = applicationRef.hostComponent.router; var router = applicationRef.hostComponent.router;
@ -67,7 +67,7 @@ export function main() {
}); });
describe('broken app', () => { describe('broken app', () => {
beforeEachBindings(() => { return [bind(appComponentTypeToken).toValue(BrokenAppCmp)]; }); beforeEachBindings(() => { return [bind(APP_COMPONENT).toValue(BrokenAppCmp)]; });
it('should rethrow exceptions from component constructors', it('should rethrow exceptions from component constructors',
inject([AsyncTestCompleter, TestComponentBuilder], (async, tcb: TestComponentBuilder) => { inject([AsyncTestCompleter, TestComponentBuilder], (async, tcb: TestComponentBuilder) => {
@ -83,7 +83,7 @@ export function main() {
}); });
describe('back button app', () => { describe('back button app', () => {
beforeEachBindings(() => { return [bind(appComponentTypeToken).toValue(HierarchyAppCmp)]; }); beforeEachBindings(() => { return [bind(APP_COMPONENT).toValue(HierarchyAppCmp)]; });
it('should change the url without pushing a new history state for back navigations', it('should change the url without pushing a new history state for back navigations',
inject([AsyncTestCompleter, TestComponentBuilder], (async, tcb: TestComponentBuilder) => { inject([AsyncTestCompleter, TestComponentBuilder], (async, tcb: TestComponentBuilder) => {
@ -134,7 +134,7 @@ export function main() {
}); });
describe('hierarchical app', () => { describe('hierarchical app', () => {
beforeEachBindings(() => { return [bind(appComponentTypeToken).toValue(HierarchyAppCmp)]; }); beforeEachBindings(() => { return [bind(APP_COMPONENT).toValue(HierarchyAppCmp)]; });
it('should bootstrap an app with a hierarchy', it('should bootstrap an app with a hierarchy',
inject([AsyncTestCompleter, TestComponentBuilder], (async, tcb: TestComponentBuilder) => { inject([AsyncTestCompleter, TestComponentBuilder], (async, tcb: TestComponentBuilder) => {
@ -152,7 +152,7 @@ export function main() {
})); }));
describe('custom app base ref', () => { describe('custom app base ref', () => {
beforeEachBindings(() => { return [bind(appBaseHrefToken).toValue('/my/app')]; }); beforeEachBindings(() => { return [bind(APP_BASE_HREF).toValue('/my/app')]; });
it('should bootstrap', inject([AsyncTestCompleter, TestComponentBuilder], it('should bootstrap', inject([AsyncTestCompleter, TestComponentBuilder],
(async, tcb: TestComponentBuilder) => { (async, tcb: TestComponentBuilder) => {
@ -174,8 +174,7 @@ export function main() {
// TODO: add a test in which the child component has bindings // TODO: add a test in which the child component has bindings
describe('querystring params app', () => { describe('querystring params app', () => {
beforeEachBindings( beforeEachBindings(() => { return [bind(APP_COMPONENT).toValue(QueryStringAppCmp)]; });
() => { return [bind(appComponentTypeToken).toValue(QueryStringAppCmp)]; });
it('should recognize and return querystring params with the injected RouteParams', it('should recognize and return querystring params with the injected RouteParams',
inject([AsyncTestCompleter, TestComponentBuilder], (async, tcb: TestComponentBuilder) => { inject([AsyncTestCompleter, TestComponentBuilder], (async, tcb: TestComponentBuilder) => {

View File

@ -1,9 +1,9 @@
/// <reference path="../../../angular2/typings/rx/rx.d.ts" /> /// <reference path="../../../angular2/typings/rx/rx.d.ts" />
import {bootstrap} from 'angular2/bootstrap'; import {bootstrap} from 'angular2/bootstrap';
import {httpInjectables} from 'http/http'; import {HTTP_BINDINGS} from 'http/http';
import {HttpCmp} from './http_comp'; import {HttpCmp} from './http_comp';
export function main() { export function main() {
bootstrap(HttpCmp, [httpInjectables]); bootstrap(HttpCmp, [HTTP_BINDINGS]);
} }

View File

@ -1,8 +1,8 @@
import {HttpCmp} from './http_comp'; import {HttpCmp} from './http_comp';
import {bootstrap} from 'angular2/bootstrap'; import {bootstrap} from 'angular2/bootstrap';
import {httpInjectables} from 'http/http'; import {HTTP_BINDINGS} from 'http/http';
export function main() { export function main() {
// This entry point is not transformed and exists for testing dynamic mode. // This entry point is not transformed and exists for testing dynamic mode.
bootstrap(HttpCmp, [httpInjectables]); bootstrap(HttpCmp, [HTTP_BINDINGS]);
} }

View File

@ -1,9 +1,9 @@
/// <reference path="../../../angular2/typings/rx/rx.d.ts" /> /// <reference path="../../../angular2/typings/rx/rx.d.ts" />
import {bootstrap} from 'angular2/bootstrap'; import {bootstrap} from 'angular2/bootstrap';
import {jsonpInjectables} from 'http/http'; import {JSONP_BINDINGS} from 'http/http';
import {JsonpCmp} from './jsonp_comp'; import {JsonpCmp} from './jsonp_comp';
export function main() { export function main() {
bootstrap(JsonpCmp, [jsonpInjectables]); bootstrap(JsonpCmp, [JSONP_BINDINGS]);
} }

View File

@ -1,7 +1,7 @@
import {JsonpCmp} from './jsonp_comp'; import {JsonpCmp} from './jsonp_comp';
import {bootstrap} from 'angular2/bootstrap'; import {bootstrap} from 'angular2/bootstrap';
import {jsonpInjectables} from 'http/http'; import {JSONP_BINDINGS} from 'http/http';
export function main() { export function main() {
bootstrap(JsonpCmp, [jsonpInjectables]); bootstrap(JsonpCmp, [JSONP_BINDINGS]);
} }

View File

@ -1,5 +1,5 @@
import {bootstrap, NgIf, NgFor, Component, Directive, View, Host} from 'angular2/bootstrap'; import {bootstrap, NgIf, NgFor, Component, Directive, View, Host} from 'angular2/bootstrap';
import {formDirectives, NgControl, Validators, NgFormModel, FormBuilder} from 'angular2/forms'; import {FORM_DIRECTIVES, NgControl, Validators, NgFormModel, FormBuilder} from 'angular2/forms';
import {RegExpWrapper, print, isPresent} from 'angular2/src/facade/lang'; import {RegExpWrapper, print, isPresent} from 'angular2/src/facade/lang';
@ -117,7 +117,7 @@ class ShowError {
<button type="submit" [disabled]="!f.form.valid">Submit</button> <button type="submit" [disabled]="!f.form.valid">Submit</button>
</form> </form>
`, `,
directives: [formDirectives, NgFor, ShowError] directives: [FORM_DIRECTIVES, NgFor, ShowError]
}) })
class ModelDrivenForms { class ModelDrivenForms {
form; form;

View File

@ -14,7 +14,7 @@ import {
import {Injectable} from 'angular2/di'; import {Injectable} from 'angular2/di';
import {formDirectives} from 'angular2/forms'; import {FORM_DIRECTIVES} from 'angular2/forms';
import {ListWrapper} from 'angular2/src/facade/collection'; import {ListWrapper} from 'angular2/src/facade/collection';
@ -109,7 +109,7 @@ class DataService {
<button (click)="select(order)">Select</button> <button (click)="select(order)">Select</button>
</div> </div>
`, `,
directives: [formDirectives, NgFor] directives: [FORM_DIRECTIVES, NgFor]
}) })
class OrderListComponent { class OrderListComponent {
orders: Order[]; orders: Order[];
@ -143,7 +143,7 @@ class OrderListComponent {
<button (click)="onDelete()">Delete</button> <button (click)="onDelete()">Delete</button>
</div> </div>
`, `,
directives: [formDirectives] directives: [FORM_DIRECTIVES]
}) })
class OrderItemComponent { class OrderItemComponent {
item: OrderItem; item: OrderItem;
@ -180,7 +180,7 @@ class OrderItemComponent {
<order-item-cmp *ng-for="#item of order.items" [item]="item" (delete)="deleteItem(item)"></order-item-cmp> <order-item-cmp *ng-for="#item of order.items" [item]="item" (delete)="deleteItem(item)"></order-item-cmp>
</div> </div>
`, `,
directives: [formDirectives, OrderItemComponent, NgFor, NgIf] directives: [FORM_DIRECTIVES, OrderItemComponent, NgFor, NgIf]
}) })
class OrderDetailsComponent { class OrderDetailsComponent {
constructor(private service: DataService) {} constructor(private service: DataService) {}

View File

@ -13,7 +13,7 @@ import {
import {Injectable} from 'angular2/di'; import {Injectable} from 'angular2/di';
import {formDirectives} from 'angular2/forms'; import {FORM_DIRECTIVES} from 'angular2/forms';
import {CONST_EXPR} from 'angular2/src/facade/lang'; import {CONST_EXPR} from 'angular2/src/facade/lang';
@ -113,7 +113,7 @@ class DataService {
</form> </form>
</div> </div>
`, `,
directives: [formDirectives] directives: [FORM_DIRECTIVES]
}) })
class FullNameComponent { class FullNameComponent {
constructor(private service: DataService) {} constructor(private service: DataService) {}
@ -161,7 +161,7 @@ class FullNameComponent {
</form> </form>
</div> </div>
`, `,
directives: [formDirectives, NgIf] directives: [FORM_DIRECTIVES, NgIf]
}) })
class PersonsDetailComponent { class PersonsDetailComponent {
constructor(private service: DataService) {} constructor(private service: DataService) {}
@ -182,7 +182,7 @@ class PersonsDetailComponent {
<person-detail-cmp></person-detail-cmp> <person-detail-cmp></person-detail-cmp>
</div> </div>
`, `,
directives: [formDirectives, PersonsDetailComponent, NgFor] directives: [FORM_DIRECTIVES, PersonsDetailComponent, NgFor]
}) })
class PersonsComponent { class PersonsComponent {
persons: Person[]; persons: Person[];

View File

@ -2,7 +2,7 @@ import {InboxApp} from './inbox-app';
import {bind} from 'angular2/angular2'; import {bind} from 'angular2/angular2';
import {bootstrap} from 'angular2/bootstrap'; import {bootstrap} from 'angular2/bootstrap';
import {routerInjectables, HashLocationStrategy, LocationStrategy} from 'angular2/router'; import {routerInjectables, HashLocationStrategy, LocationStrategy} from 'angular2/router';
import {httpInjectables} from 'http/http'; import {HTTP_BINDINGS} from 'http/http';
import {reflector} from 'angular2/src/reflection/reflection'; import {reflector} from 'angular2/src/reflection/reflection';
import {ReflectionCapabilities} from 'angular2/src/reflection/reflection_capabilities'; import {ReflectionCapabilities} from 'angular2/src/reflection/reflection_capabilities';
@ -11,5 +11,5 @@ export function main() {
reflector.reflectionCapabilities = new ReflectionCapabilities(); reflector.reflectionCapabilities = new ReflectionCapabilities();
bootstrap( bootstrap(
InboxApp, InboxApp,
[routerInjectables, httpInjectables, bind(LocationStrategy).toClass(HashLocationStrategy)]); [routerInjectables, HTTP_BINDINGS, bind(LocationStrategy).toClass(HashLocationStrategy)]);
} }

View File

@ -10,7 +10,7 @@ import {
forwardRef, forwardRef,
Binding Binding
} from 'angular2/bootstrap'; } from 'angular2/bootstrap';
import {formDirectives, NgControl, Validators, NgForm} from 'angular2/forms'; import {FORM_DIRECTIVES, NgControl, Validators, NgForm} from 'angular2/forms';
import {RegExpWrapper, print, isPresent, CONST_EXPR} from 'angular2/src/facade/lang'; import {RegExpWrapper, print, isPresent, CONST_EXPR} from 'angular2/src/facade/lang';
@ -151,7 +151,7 @@ class ShowError {
<button type="submit" [disabled]="!f.form.valid">Submit</button> <button type="submit" [disabled]="!f.form.valid">Submit</button>
</form> </form>
`, `,
directives: [formDirectives, NgFor, CreditCardValidator, ShowError] directives: [FORM_DIRECTIVES, NgFor, CreditCardValidator, ShowError]
}) })
class TemplateDrivenForms { class TemplateDrivenForms {
model = new CheckoutModel(); model = new CheckoutModel();

View File

@ -1,11 +1,11 @@
import {NgZone, NgFor, Component, View, NgIf, formDirectives} from 'angular2/angular2'; import {NgZone, NgFor, Component, View, NgIf, FORM_DIRECTIVES} from 'angular2/angular2';
import {BitmapService} from './services/bitmap'; import {BitmapService} from './services/bitmap';
import {EventListener} from 'angular2/src/facade/browser'; import {EventListener} from 'angular2/src/facade/browser';
import {FileReader, Uint8ArrayWrapper} from './file_api'; import {FileReader, Uint8ArrayWrapper} from './file_api';
import {TimerWrapper} from 'angular2/src/facade/async'; import {TimerWrapper} from 'angular2/src/facade/async';
@Component({selector: 'image-demo', viewBindings: [BitmapService]}) @Component({selector: 'image-demo', viewBindings: [BitmapService]})
@View({templateUrl: 'image_demo.html', directives: [NgFor, NgIf, formDirectives]}) @View({templateUrl: 'image_demo.html', directives: [NgFor, NgIf, FORM_DIRECTIVES]})
export class ImageDemo { export class ImageDemo {
images = []; images = [];
fileInput: String; fileInput: String;

View File

@ -1,8 +1,8 @@
import {NgFor, Component, View, formDirectives} from 'angular2/angular2'; import {NgFor, Component, View, FORM_DIRECTIVES} from 'angular2/angular2';
import {Store, Todo, TodoFactory} from './services/TodoStore'; import {Store, Todo, TodoFactory} from './services/TodoStore';
@Component({selector: 'todo-app', viewBindings: [Store, TodoFactory]}) @Component({selector: 'todo-app', viewBindings: [Store, TodoFactory]})
@View({templateUrl: 'todo.html', directives: [NgFor, formDirectives]}) @View({templateUrl: 'todo.html', directives: [NgFor, FORM_DIRECTIVES]})
export class TodoApp { export class TodoApp {
todoEdit: Todo = null; todoEdit: Todo = null;
inputValue: string; inputValue: string;

View File

@ -50,8 +50,8 @@ export {URLSearchParams} from 'http/src/url_search_params';
* #Example * #Example
* *
* ``` * ```
* import {httpInjectables, Http} from 'http/http'; * import {HTTP_BINDINGS, Http} from 'http/http';
* @Component({selector: 'http-app', viewBindings: [httpInjectables]}) * @Component({selector: 'http-app', viewBindings: [HTTP_BINDINGS]})
* @View({template: '{{data}}'}) * @View({template: '{{data}}'})
* class MyApp { * class MyApp {
* constructor(http:Http) { * constructor(http:Http) {
@ -61,7 +61,7 @@ export {URLSearchParams} from 'http/src/url_search_params';
* ``` * ```
* *
*/ */
export var httpInjectables: List<any> = [ export const HTTP_BINDINGS: List<any> = [
bind(ConnectionBackend) bind(ConnectionBackend)
.toClass(XHRBackend), .toClass(XHRBackend),
BrowserXhr, BrowserXhr,
@ -70,7 +70,7 @@ export var httpInjectables: List<any> = [
Http Http
]; ];
export var jsonpInjectables: List<any> = [ export const JSONP_BINDINGS: List<any> = [
bind(ConnectionBackend) bind(ConnectionBackend)
.toClass(JSONPBackend), .toClass(JSONPBackend),
BrowserJsonp, BrowserJsonp,

View File

@ -1,6 +1,6 @@
require('reflect-metadata'); require('reflect-metadata');
require('traceur-runtime'); require('traceur-runtime');
import {httpInjectables, jsonpInjectables, Http, Jsonp} from './http'; import {HTTP_BINDINGS, JSONP_BINDINGS, Http, Jsonp} from './http';
import {Injector} from 'angular2/angular2'; import {Injector} from 'angular2/angular2';
export * from './http'; export * from './http';
@ -8,5 +8,5 @@ export * from './http';
* TODO(jeffbcross): export each as their own top-level file, to require as: * TODO(jeffbcross): export each as their own top-level file, to require as:
* require('http/http'); require('http/jsonp'); * require('http/http'); require('http/jsonp');
*/ */
export var http = Injector.resolveAndCreate([httpInjectables]).get(Http); export var http = Injector.resolveAndCreate([HTTP_BINDINGS]).get(Http);
export var jsonp = Injector.resolveAndCreate([jsonpInjectables]).get(Jsonp); export var jsonp = Injector.resolveAndCreate([JSONP_BINDINGS]).get(Jsonp);

View File

@ -84,11 +84,10 @@ export class XHRConnection implements Connection {
* #Example * #Example
* *
* ``` * ```
* import {Http, MyNodeBackend, httpInjectables, BaseRequestOptions} from * import {Http, MyNodeBackend, HTTP_BINDINGS, BaseRequestOptions} from 'http/http';
*'angular2/http';
* @Component({ * @Component({
* viewBindings: [ * viewBindings: [
* httpInjectables, * HTTP_BINDINGS,
* bind(Http).toFactory((backend, options) => { * bind(Http).toFactory((backend, options) => {
* return new Http(backend, options); * return new Http(backend, options);
* }, [MyNodeBackend, BaseRequestOptions])] * }, [MyNodeBackend, BaseRequestOptions])]

View File

@ -52,8 +52,8 @@ function mergeOptions(defaultOpts, providedOpts, method, url): RequestOptions {
* #Example * #Example
* *
* ``` * ```
* import {Http, httpInjectables} from 'angular2/http'; * import {Http, HTTP_BINDINGS} from 'angular2/http';
* @Component({selector: 'http-app', viewBindings: [httpInjectables]}) * @Component({selector: 'http-app', viewBindings: [HTTP_BINDINGS]})
* @View({templateUrl: 'people.html'}) * @View({templateUrl: 'people.html'})
* class PeopleComponent { * class PeopleComponent {
* constructor(http: Http) { * constructor(http: Http) {