cleanup(di): renamed viewInjector and hostInjector

BREAKING CHANGE
    Replace viewInjector with viewBindings
    Replace hostInjector with bindings
This commit is contained in:
vsavkin 2015-07-29 15:01:22 -07:00
parent 70bc485755
commit 3cda7128d0
34 changed files with 126 additions and 119 deletions

View File

@ -216,7 +216,7 @@ To better understand the kinds of injections which are supported in Angular we h
### Injecting Services
Service injection is the most straight forward kind of injection which Angular supports. It involves a component configuring the `viewInjector` or `hostInjector` and then letting the directive ask for the configured service.
Service injection is the most straight forward kind of injection which Angular supports. It involves a component configuring the `bindings` or `viewBindings` and then letting the directive ask for the configured service.
This example illustrates how to inject `MyService` into `House` directive.
@ -227,7 +227,7 @@ class MyService {} | Assume a service which needs to be inject
|
@Component({ | Assume a top level application component which
selector: 'my-app', | configures the services to be injected.
viewInjector: [MyService] |
viewBindings: [MyService] |
}) |
@View({ | Assume we have a template that needs to be
templateUrl: 'my_app.html', | configured with directives to be injected.
@ -361,7 +361,7 @@ class Dad {
@Component({
selector: '[grandpa]',
viewInjector: []
viewBindings: []
})
@View({
templateUrl: 'grandpa.html',

View File

@ -51,7 +51,7 @@ export {URLSearchParams} from 'angular2/src/http/url_search_params';
*
* ```
* import {httpInjectables, Http} from 'angular2/http';
* @Component({selector: 'http-app', viewInjector: [httpInjectables]})
* @Component({selector: 'http-app', viewBindings: [httpInjectables]})
* @View({template: '{{data}}'})
* class MyApp {
* constructor(http:Http) {

View File

@ -19,7 +19,7 @@ export class Pipes {
* 'json': [jsonPipeFactory]
* }
* @Component({
* viewInjector: [
* viewBindings: [
* bind(Pipes).toValue(new Pipes(pipesConfig))
* ]
* })
@ -61,7 +61,7 @@ export class Pipes {
*
* ```
* @Component({
* viewInjector: [
* viewBindings: [
* Pipes.extend({
* async: [newAsyncPipe]
* })

View File

@ -99,13 +99,13 @@ export interface ViewDecorator extends TypeDecorator {
export interface DirectiveFactory {
(obj: {
selector?: string, properties?: List<string>, events?: List<string>,
host?: StringMap<string, string>, lifecycle?: List<LifecycleEvent>,
hostInjector?: List<any>, exportAs?: string, compileChildren?: boolean;
host?: StringMap<string, string>, lifecycle?: List<LifecycleEvent>, bindings?: List<any>,
exportAs?: string, compileChildren?: boolean;
}): DirectiveDecorator;
new (obj: {
selector?: string, properties?: List<string>, events?: List<string>,
host?: StringMap<string, string>, lifecycle?: List<LifecycleEvent>,
hostInjector?: List<any>, exportAs?: string, compileChildren?: boolean;
host?: StringMap<string, string>, lifecycle?: List<LifecycleEvent>, bindings?: List<any>,
exportAs?: string, compileChildren?: boolean;
}): DirectiveAnnotation;
}
@ -159,10 +159,10 @@ export interface ComponentFactory {
events?: List<string>,
host?: StringMap<string, string>,
lifecycle?: List<LifecycleEvent>,
hostInjector?: List<any>,
bindings?: List<any>,
exportAs?: string,
compileChildren?: boolean,
viewInjector?: List<any>,
viewBindings?: List<any>,
changeDetection?: string,
}): ComponentDecorator;
new (obj: {
@ -171,10 +171,10 @@ export interface ComponentFactory {
events?: List<string>,
host?: StringMap<string, string>,
lifecycle?: List<LifecycleEvent>,
hostInjector?: List<any>,
bindings?: List<any>,
exportAs?: string,
compileChildren?: boolean,
viewInjector?: List<any>,
viewBindings?: List<any>,
changeDetection?: string,
}): ComponentAnnotation;
}

View File

@ -710,7 +710,7 @@ export class Directive extends InjectableMetadata {
*
* @Directive({
* selector: 'greet',
* hostInjector: [
* bindings: [
* Greeter
* ]
* })
@ -723,7 +723,7 @@ export class Directive extends InjectableMetadata {
* }
* ```
*/
hostInjector: List<any>;
bindings: List<any>;
/**
* Defines the name that can be used in the template to assign this directive to a variable.
@ -753,7 +753,7 @@ export class Directive extends InjectableMetadata {
exportAs: string;
constructor({
selector, properties, events, host, lifecycle, hostInjector, exportAs,
selector, properties, events, host, lifecycle, bindings, exportAs,
compileChildren = true,
}: {
selector?: string,
@ -761,7 +761,7 @@ export class Directive extends InjectableMetadata {
events?: List<string>,
host?: StringMap<string, string>,
lifecycle?: List<LifecycleEvent>,
hostInjector?: List<any>,
bindings?: List<any>,
exportAs?: string,
compileChildren?: boolean,
} = {}) {
@ -773,7 +773,7 @@ export class Directive extends InjectableMetadata {
this.exportAs = exportAs;
this.lifecycle = lifecycle;
this.compileChildren = compileChildren;
this.hostInjector = hostInjector;
this.bindings = bindings;
}
}
@ -788,7 +788,7 @@ export class Directive extends InjectableMetadata {
* When a component is instantiated, Angular
* - creates a shadow DOM for the component.
* - loads the selected template into the shadow DOM.
* - creates all the injectable objects configured with `hostInjector` and `viewInjector`.
* - creates all the injectable objects configured with `bindings` and `viewBindings`.
*
* All template expressions and statements are then evaluated against the component instance.
*
@ -855,7 +855,7 @@ export class Component extends Directive {
*
* @Component({
* selector: 'greet',
* viewInjector: [
* viewBindings: [
* Greeter
* ]
* })
@ -868,19 +868,19 @@ export class Component extends Directive {
*
* ```
*/
viewInjector: List<any>;
viewBindings: List<any>;
constructor({selector, properties, events, host, exportAs, lifecycle, hostInjector, viewInjector,
constructor({selector, properties, events, host, exportAs, lifecycle, bindings, viewBindings,
changeDetection = DEFAULT, compileChildren = true}: {
selector?: string,
properties?: List<string>,
events?: List<string>,
host?: StringMap<string, string>,
lifecycle?: List<LifecycleEvent>,
hostInjector?: List<any>,
bindings?: List<any>,
exportAs?: string,
compileChildren?: boolean,
viewInjector?: List<any>,
viewBindings?: List<any>,
changeDetection?: string,
} = {}) {
super({
@ -889,13 +889,13 @@ export class Component extends Directive {
events: events,
host: host,
exportAs: exportAs,
hostInjector: hostInjector,
bindings: bindings,
lifecycle: lifecycle,
compileChildren: compileChildren
});
this.changeDetection = changeDetection;
this.viewInjector = viewInjector;
this.viewBindings = viewBindings;
}
}

View File

@ -200,8 +200,8 @@ export class DirectiveDependency extends Dependency {
export class DirectiveBinding extends ResolvedBinding {
constructor(key: Key, factory: Function, dependencies: List<Dependency>,
public resolvedHostInjectables: List<ResolvedBinding>,
public resolvedViewInjectables: List<ResolvedBinding>,
public resolvedBindings: List<ResolvedBinding>,
public resolvedViewBindings: List<ResolvedBinding>,
public metadata: DirectiveMetadata) {
super(key, factory, dependencies);
}
@ -233,11 +233,10 @@ export class DirectiveBinding extends ResolvedBinding {
var rb = binding.resolve();
var deps = ListWrapper.map(rb.dependencies, DirectiveDependency.createFrom);
var resolvedHostInjectables =
isPresent(ann.hostInjector) ? Injector.resolve(ann.hostInjector) : [];
var resolvedViewInjectables = ann instanceof Component && isPresent(ann.viewInjector) ?
Injector.resolve(ann.viewInjector) :
[];
var resolvedBindings = isPresent(ann.bindings) ? Injector.resolve(ann.bindings) : [];
var resolvedViewBindings = ann instanceof Component && isPresent(ann.viewBindings) ?
Injector.resolve(ann.viewBindings) :
[];
var metadata = DirectiveMetadata.create({
id: stringify(rb.key.token),
type: ann instanceof Component ? DirectiveMetadata.COMPONENT_TYPE :
@ -259,8 +258,8 @@ export class DirectiveBinding extends ResolvedBinding {
exportAs: ann.exportAs
});
return new DirectiveBinding(rb.key, rb.factory, deps, resolvedHostInjectables,
resolvedViewInjectables, metadata);
return new DirectiveBinding(rb.key, rb.factory, deps, resolvedBindings, resolvedViewBindings,
metadata);
}
static _readAttributes(deps) {
@ -353,10 +352,9 @@ export class ProtoElementInjector {
ProtoElementInjector._createDirectiveBindingWithVisibility(bindings, bd,
firstBindingIsComponent);
if (firstBindingIsComponent) {
ProtoElementInjector._createViewInjectorBindingWithVisibility(bindings, bd);
ProtoElementInjector._createViewBindingsWithVisibility(bindings, bd);
}
ProtoElementInjector._createHostInjectorBindingWithVisibility(bindings, bd,
firstBindingIsComponent);
ProtoElementInjector._createBindingsWithVisibility(bindings, bd, firstBindingIsComponent);
return new ProtoElementInjector(parent, index, bd, distanceToParent, firstBindingIsComponent,
directiveVariableBindings);
}
@ -370,11 +368,11 @@ export class ProtoElementInjector {
});
}
private static _createHostInjectorBindingWithVisibility(dirBindings: List<ResolvedBinding>,
bd: BindingWithVisibility[],
firstBindingIsComponent: boolean) {
private static _createBindingsWithVisibility(dirBindings: List<ResolvedBinding>,
bd: BindingWithVisibility[],
firstBindingIsComponent: boolean) {
ListWrapper.forEach(dirBindings, dirBinding => {
ListWrapper.forEach(dirBinding.resolvedHostInjectables, b => {
ListWrapper.forEach(dirBinding.resolvedBindings, b => {
bd.push(ProtoElementInjector._createBindingWithVisibility(firstBindingIsComponent,
dirBinding, dirBindings, b));
});
@ -387,10 +385,10 @@ export class ProtoElementInjector {
return new BindingWithVisibility(binding, isComponent ? PUBLIC_AND_PRIVATE : PUBLIC);
}
private static _createViewInjectorBindingWithVisibility(bindings: List<ResolvedBinding>,
bd: BindingWithVisibility[]) {
private static _createViewBindingsWithVisibility(bindings: List<ResolvedBinding>,
bd: BindingWithVisibility[]) {
var db = <DirectiveBinding>bindings[0];
ListWrapper.forEach(db.resolvedViewInjectables,
ListWrapper.forEach(db.resolvedViewBindings,
b => bd.push(new BindingWithVisibility(b, PRIVATE)));
}

View File

@ -50,7 +50,7 @@ const controlGroupBinding =
*/
@Directive({
selector: '[ng-control-group]',
hostInjector: [controlGroupBinding],
bindings: [controlGroupBinding],
properties: ['name: ng-control-group'],
lifecycle: [LifecycleEvent.onInit, LifecycleEvent.onDestroy],
exportAs: 'form'

View File

@ -73,7 +73,7 @@ const controlNameBinding =
*/
@Directive({
selector: '[ng-control]',
hostInjector: [controlNameBinding],
bindings: [controlNameBinding],
properties: ['name: ngControl', 'model: ngModel'],
events: ['update: ngModel'],
lifecycle: [LifecycleEvent.onDestroy, LifecycleEvent.onChange],

View File

@ -52,7 +52,7 @@ const formDirectiveBinding =
*/
@Directive({
selector: 'form:not([ng-no-form]):not([ng-form-model]),ng-form,[ng-form]',
hostInjector: [formDirectiveBinding],
bindings: [formDirectiveBinding],
host: {
'(submit)': 'onSubmit()',
},

View File

@ -60,7 +60,7 @@ const formControlBinding =
*/
@Directive({
selector: '[ng-form-control]',
hostInjector: [formControlBinding],
bindings: [formControlBinding],
properties: ['form: ngFormControl', 'model: ngModel'],
events: ['update: ngModel'],
lifecycle: [LifecycleEvent.onChange],

View File

@ -82,7 +82,7 @@ const formDirectiveBinding =
*/
@Directive({
selector: '[ng-form-model]',
hostInjector: [formDirectiveBinding],
bindings: [formDirectiveBinding],
properties: ['form: ng-form-model'],
lifecycle: [LifecycleEvent.onChange],
host: {

View File

@ -30,7 +30,7 @@ const formControlBinding = CONST_EXPR(new Binding(NgControl, {toAlias: forwardRe
*/
@Directive({
selector: '[ng-model]:not([ng-control]):not([ng-form-control])',
hostInjector: [formControlBinding],
bindings: [formControlBinding],
properties: ['model: ngModel'],
events: ['update: ngModel'],
lifecycle: [LifecycleEvent.onChange],

View File

@ -12,7 +12,7 @@ const requiredValidatorBinding =
@Directive({
selector: '[required][ng-control],[required][ng-form-control],[required][ng-model]',
hostInjector: [requiredValidatorBinding]
bindings: [requiredValidatorBinding]
})
export class NgRequiredValidator extends NgValidator {
get validator(): Function { return Validators.required; }

View File

@ -15,7 +15,7 @@ import * as modelModule from './model';
*
* @Component({
* selector: 'login-comp',
* viewInjector: [
* viewBindings: [
* FormBuilder
* ]
* })

View File

@ -73,7 +73,7 @@ export class XHRConnection implements Connection {
* ```
* import {Http, MyNodeBackend, httpInjectables, BaseRequestOptions} from 'angular2/http';
* @Component({
* viewInjector: [
* viewBindings: [
* httpInjectables,
* bind(Http).toFactory((backend, options) => {
* return new Http(backend, options);

View File

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

View File

@ -264,7 +264,7 @@ class DynamicallyCreatedComponentService {}
@Component({
selector: 'hello-cmp',
viewInjector: [DynamicallyCreatedComponentService],
viewBindings: [DynamicallyCreatedComponentService],
lifecycle: [LifecycleEvent.onDestroy]
})
@View({template: "{{greeting}}"})

View File

@ -447,13 +447,13 @@ export function main() {
});
describe(".create", () => {
it("should collect hostInjector injectables from all directives", () => {
it("should collect bindings from all directives", () => {
var pei = createPei(null, 0, [
DirectiveBinding.createFromType(
SimpleDirective,
new dirAnn.Component({hostInjector: [bind('injectable1').toValue('injectable1')]})),
new dirAnn.Component({bindings: [bind('injectable1').toValue('injectable1')]})),
DirectiveBinding.createFromType(SomeOtherDirective, new dirAnn.Component({
hostInjector: [bind('injectable2').toValue('injectable2')]
bindings: [bind('injectable2').toValue('injectable2')]
}))
]);
@ -463,10 +463,10 @@ export function main() {
expect(pei.getBindingAtIndex(3).key.token).toEqual("injectable2");
});
it("should collect viewInjector injectables from the component", () => {
it("should collect view bindings from the component", () => {
var pei = createPei(null, 0,
[DirectiveBinding.createFromType(SimpleDirective, new dirAnn.Component({
viewInjector: [bind('injectable1').toValue('injectable1')]
viewBindings: [bind('injectable1').toValue('injectable1')]
}))],
0, true);
@ -474,13 +474,13 @@ export function main() {
expect(pei.getBindingAtIndex(1).key.token).toEqual("injectable1");
});
it("should collect view and host injectables from nested arrays", () => {
it("should flatten nested arrays", () => {
var pei = createPei(null, 0, [
DirectiveBinding.createFromType(
SimpleDirective,
new dirAnn.Component({
viewInjector: [[[bind('view').toValue('view')]]],
hostInjector: [[[bind('host').toValue('host')]]]
viewBindings: [[[bind('view').toValue('view')]]],
bindings: [[[bind('host').toValue('host')]]]
}))
], 0, true);
@ -582,16 +582,16 @@ export function main() {
expect(d.dependency).toBeAnInstanceOf(SimpleDirective);
});
it("should instantiate hostInjector injectables that have dependencies with set visibility",
it("should instantiate bindings that have dependencies with set visibility",
function() {
var childInj = parentChildInjectors(
ListWrapper.concat(
[DirectiveBinding.createFromType(SimpleDirective, new dirAnn.Component({
hostInjector: [bind('injectable1').toValue('injectable1')]
bindings: [bind('injectable1').toValue('injectable1')]
}))],
extraBindings),
[DirectiveBinding.createFromType(SimpleDirective, new dirAnn.Component({
hostInjector: [
bindings: [
bind('injectable1')
.toValue('new-injectable1'),
bind('injectable2')
@ -603,8 +603,8 @@ export function main() {
expect(childInj.get('injectable2')).toEqual('injectable1-injectable2');
});
it("should instantiate hostInjector injectables that have dependencies", () => {
var hostInjector = [
it("should instantiate bindings that have dependencies", () => {
var bindings = [
bind('injectable1')
.toValue('injectable1'),
bind('injectable2')
@ -615,14 +615,14 @@ export function main() {
var inj = injector(ListWrapper.concat(
[DirectiveBinding.createFromType(SimpleDirective,
new dirAnn.Directive({hostInjector: hostInjector}))],
new dirAnn.Directive({bindings: bindings}))],
extraBindings));
expect(inj.get('injectable2')).toEqual('injectable1-injectable2');
});
it("should instantiate viewInjector injectables that have dependencies", () => {
var viewInjector = [
it("should instantiate viewBindings that have dependencies", () => {
var viewBindings = [
bind('injectable1')
.toValue('injectable1'),
bind('injectable2')
@ -634,26 +634,26 @@ export function main() {
var inj = injector(ListWrapper.concat(
[DirectiveBinding.createFromType(SimpleDirective, new dirAnn.Component({
viewInjector: viewInjector}))], extraBindings),
viewBindings: viewBindings}))], extraBindings),
null, true);
expect(inj.get('injectable2')).toEqual('injectable1-injectable2');
});
it("should instantiate components that depend on viewInjector bindings", () => {
it("should instantiate components that depend on viewBindings bindings", () => {
var inj = injector(
ListWrapper.concat([DirectiveBinding.createFromType(NeedsService, new dirAnn.Component({
viewInjector: [bind('service').toValue('service')]
viewBindings: [bind('service').toValue('service')]
}))],
extraBindings),
null, true);
expect(inj.get(NeedsService).service).toEqual('service');
});
it("should instantiate hostInjector injectables lazily", () => {
it("should instantiate bindings lazily", () => {
var created = false;
var inj = injector(
ListWrapper.concat([DirectiveBinding.createFromType(SimpleDirective, new dirAnn.Component({
hostInjector: [bind('service').toFactory(() => created = true)]
bindings: [bind('service').toFactory(() => created = true)]
}))],
extraBindings),
null, true);
@ -665,11 +665,11 @@ export function main() {
expect(created).toBe(true);
});
it("should instantiate viewInjector injectables lazily", () => {
it("should instantiate view bindings lazily", () => {
var created = false;
var inj = injector(
ListWrapper.concat([DirectiveBinding.createFromType(SimpleDirective, new dirAnn.Component({
viewInjector: [bind('service').toFactory(() => created = true)]
viewBindings: [bind('service').toFactory(() => created = true)]
}))],
extraBindings),
null, true);
@ -681,10 +681,10 @@ export function main() {
expect(created).toBe(true);
});
it("should not instantiate other directives that depend on viewInjector bindings",
it("should not instantiate other directives that depend on viewBindings bindings",
() => {
var directiveAnnotation = new dirAnn.Component({
viewInjector: ListWrapper.concat([bind("service").toValue("service")], extraBindings)
viewBindings: ListWrapper.concat([bind("service").toValue("service")], extraBindings)
});
var componentDirective =
DirectiveBinding.createFromType(SimpleDirective, directiveAnnotation);
@ -693,10 +693,10 @@ export function main() {
`No provider for service! (${stringify(NeedsService) } -> service)`));
});
it("should instantiate directives that depend on hostInjector bindings of other directives", () => {
it("should instantiate directives that depend on bindings bindings of other directives", () => {
var shadowInj = hostShadowInjectors(
ListWrapper.concat([DirectiveBinding.createFromType(SimpleDirective, new dirAnn.Component({
hostInjector: [bind('service').toValue('hostService')]})
bindings: [bind('service').toValue('hostService')]})
)], extraBindings),
ListWrapper.concat([NeedsService], extraBindings)
);
@ -731,23 +731,23 @@ export function main() {
expect(inj.get(NeedsServiceFromHost).service).toEqual('appService');
});
it("should prioritize viewInjector over hostInjector for the same binding", () => {
it("should prioritize viewBindings over bindings for the same binding", () => {
var inj = injector(
ListWrapper.concat([DirectiveBinding.createFromType(NeedsService, new dirAnn.Component({
hostInjector: [bind('service').toValue('hostService')],
viewInjector: [bind('service').toValue('viewService')]})
bindings: [bind('service').toValue('hostService')],
viewBindings: [bind('service').toValue('viewService')]})
)], extraBindings), null, true);
expect(inj.get(NeedsService).service).toEqual('viewService');
});
it("should not instantiate a directive in a view that has an ancestor dependency on hostInjector"+
it("should not instantiate a directive in a view that has an ancestor dependency on bindings"+
" bindings of a decorator directive", () => {
expect(() => {
hostShadowInjectors(
ListWrapper.concat([
SimpleDirective,
DirectiveBinding.createFromType(SomeOtherDirective, new dirAnn.Directive({
hostInjector: [bind('service').toValue('hostService')]})
bindings: [bind('service').toValue('hostService')]})
)], extraBindings),
ListWrapper.concat([NeedsServiceFromHost], extraBindings)
@ -856,7 +856,7 @@ export function main() {
it("should work with services", () => {
var inj = injector(ListWrapper.concat(
[DirectiveBinding.createFromType(
SimpleDirective, new dirAnn.Directive({hostInjector: [SimpleService]}))],
SimpleDirective, new dirAnn.Directive({bindings: [SimpleService]}))],
extraBindings));
inj.dehydrate();
});

View File

@ -41,7 +41,7 @@ void functionThatThrowsNonError() {
main() {
describe('TypeLiteral', () {
it('should publish via viewInjector', inject([
it('should publish via viewBindings', inject([
TestComponentBuilder,
AsyncTestCompleter
], (tb, async) {
@ -200,7 +200,7 @@ class Dummy {
@Component(
selector: 'type-literal-component',
viewInjector: const [
viewBindings: const [
const Binding(const TypeLiteral<List<String>>(),
toValue: const <String>['Hello', 'World'])
])
@ -268,7 +268,7 @@ class OnChangeComponent implements OnChange {
selector: 'component-with-observable-list',
changeDetection: ON_PUSH,
properties: const ['list'],
hostInjector: const [
bindings: const [
const Binding(Pipes,
toValue: const Pipes(const {
"iterableDiff": const [

View File

@ -998,7 +998,7 @@ export function main() {
});
describe("dependency injection", () => {
it("should support hostInjector",
it("should support bindings",
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView(MyComp, new viewAnn.View({
template: `
@ -1018,7 +1018,7 @@ export function main() {
});
}));
it("should support viewInjector",
it("should support viewBindings",
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView(DirectiveProvidingInjectableInView, new viewAnn.View({
template: `
@ -1102,7 +1102,7 @@ export function main() {
});
}));
it("should create viewInjector injectables lazily",
it("should instantiate bindings lazily",
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView(MyComp, new viewAnn.View({
template: `
@ -1548,7 +1548,7 @@ class PipesWithDouble extends Pipes {
@Component({
selector: 'my-comp-with-pipes',
viewInjector: [new Binding(Pipes, {toClass: PipesWithDouble})]
viewBindings: [new Binding(Pipes, {toClass: PipesWithDouble})]
})
@View({directives: []})
@Injectable()
@ -1572,7 +1572,7 @@ class MyComp {
throwError() { throw 'boom'; }
}
@Component({selector: 'child-cmp', properties: ['dirProp'], viewInjector: [MyService]})
@Component({selector: 'child-cmp', properties: ['dirProp'], viewBindings: [MyService]})
@View({directives: [MyDir], template: '{{ctxProp}}'})
@Injectable()
class ChildComp {
@ -1614,7 +1614,7 @@ class CompWithHost {
constructor(@Host() someComp: SomeDirective) { this.myHost = someComp; }
}
@Component({selector: '[child-cmp2]', viewInjector: [MyService]})
@Component({selector: '[child-cmp2]', viewBindings: [MyService]})
@Injectable()
class ChildComp2 {
ctxProp: string;
@ -1833,7 +1833,7 @@ function createInjectableWithLogging(inj: Injector) {
@Component({
selector: 'component-providing-logging-injectable',
hostInjector:
bindings:
[new Binding(InjectableService, {toFactory: createInjectableWithLogging, deps: [Injector]})]
})
@View({template: ''})
@ -1843,17 +1843,26 @@ class ComponentProvidingLoggingInjectable {
}
@Directive({selector: 'directive-providing-injectable', hostInjector: [[InjectableService]]})
@Directive({selector: 'directive-providing-injectable', bindings: [[InjectableService]]})
@Injectable()
class DirectiveProvidingInjectable {
}
@Component({selector: 'directive-providing-injectable', viewInjector: [[InjectableService]]})
@Component({selector: 'directive-providing-injectable', viewBindings: [[InjectableService]]})
@View({template: ''})
@Injectable()
class DirectiveProvidingInjectableInView {
}
@Component({
selector: 'directive-providing-injectable',
bindings: [new Binding(InjectableService, {toValue: 'host'})],
viewBindings: [new Binding(InjectableService, {toValue: 'view'})]
})
@View({template: ''})
@Injectable()
class DirectiveProvidingInjectableInHostAndView {
}
@Component({selector: 'directive-consuming-injectable'})
@ -1900,7 +1909,7 @@ class EventBus {
@Directive({
selector: 'grand-parent-providing-event-bus',
hostInjector: [new Binding(EventBus, {toValue: new EventBus(null, "grandparent")})]
bindings: [new Binding(EventBus, {toValue: new EventBus(null, "grandparent")})]
})
class GrandParentProvidingEventBus {
bus: EventBus;
@ -1914,7 +1923,7 @@ function createParentBus(peb) {
@Component({
selector: 'parent-providing-event-bus',
hostInjector: [
bindings: [
new Binding(EventBus,
{toFactory: createParentBus, deps: [[EventBus, new SkipSelfMetadata()]]})
]

View File

@ -29,7 +29,7 @@ export function main() {
});
}
@Component({selector: 'app', viewInjector: [forwardRef(() => Frame)]})
@Component({selector: 'app', viewBindings: [forwardRef(() => Frame)]})
@View({
template: `<door><lock></lock></door>`,
directives: [

View File

@ -66,7 +66,7 @@ class ChildComp {
constructor() { this.childBinding = 'Original'; }
}
@Component({selector: 'parent-comp', viewInjector: [Logger]})
@Component({selector: 'parent-comp', viewBindings: [Logger]})
@View({
template: `<div class="parent" message="parent">
<span class="parentnested" message="nestedparent">Parent</span>
@ -110,7 +110,7 @@ class EventsComp {
handleCustom() { this.customed = true; }
}
@Component({selector: 'using-for', viewInjector: [Logger]})
@Component({selector: 'using-for', viewBindings: [Logger]})
@View({
template: `<span *ng-for="#thing of stuff">{{thing}}</span>
<ul message="list">

View File

@ -13,6 +13,6 @@ void initReflector() {
_ngRef.reflector
..registerType(MyComponent, new ReflectionInfo(const [
const Component(
selector: '[soup]', viewInjector: const [dep.DependencyComponent])
selector: '[soup]', viewBindings: const [dep.DependencyComponent])
], const [], () => new MyComponent()));
}

View File

@ -14,7 +14,7 @@ void initReflector() {
_ngRef.reflector
..registerType(MyComponent, new ReflectionInfo(const [
const Component(
selector: '[soup]', viewInjector: const [dep.DependencyComponent])
selector: '[soup]', viewBindings: const [dep.DependencyComponent])
], const [], () => new MyComponent()));
i0.initReflector();
}

View File

@ -29,7 +29,7 @@ class RedDec {
selector: 'hello-app',
// These are services that would be created if a class in the component's
// template tries to inject them.
viewInjector: [GreetingService]
viewBindings: [GreetingService]
})
// The template for the component.
@View({

View File

@ -12,7 +12,7 @@ import {isPresent} from 'angular2/src/facade/lang';
@Component({
selector: 'demo-app',
viewInjector: [MdDialog],
viewBindings: [MdDialog],
})
@View({
templateUrl: './demo_app.html',

View File

@ -5,7 +5,7 @@ import {UrlResolver} from 'angular2/src/services/url_resolver';
import {commonDemoSetup, DemoUrlResolver} from '../demo_common';
import {bind} from 'angular2/di';
@Component({selector: 'demo-app', viewInjector: [MdRadioDispatcher]})
@Component({selector: 'demo-app', viewBindings: [MdRadioDispatcher]})
@View({templateUrl: './demo_app.html', directives: [MdRadioGroup, MdRadioButton]})
class DemoApp {
thirdValue;

View File

@ -69,7 +69,7 @@ class ShowError {
}
@Component({selector: 'model-driven-forms', viewInjector: [FormBuilder]})
@Component({selector: 'model-driven-forms', viewBindings: [FormBuilder]})
@View({
template: `
<h1>Checkout Form (Model Driven)</h1>

View File

@ -193,7 +193,7 @@ class OrderDetailsComponent {
addItem(): void { this.service.addItemForOrder(this.order); }
}
@Component({selector: 'order-management-app', viewInjector: [DataService]})
@Component({selector: 'order-management-app', viewBindings: [DataService]})
@View({
template: `
<order-list-cmp></order-list-cmp>

View File

@ -194,7 +194,7 @@ class PersonsComponent {
}
@Component({selector: 'person-management-app', viewInjector: [DataService]})
@Component({selector: 'person-management-app', viewBindings: [DataService]})
@View({
template: `
<button (click)="switchToEditName()">Edit Full Name</button>

View File

@ -133,7 +133,7 @@ class DraftsCmp {
}
}
@Component({selector: 'inbox-app', viewInjector: [DbService]})
@Component({selector: 'inbox-app', viewBindings: [DbService]})
@View({templateUrl: "inbox-app.html", directives: [RouterOutlet, RouterLink]})
@RouteConfig([
new Route({path: '/', component: InboxCmp, as: 'inbox'}),

View File

@ -36,7 +36,7 @@ class CheckoutModel {
const creditCardValidatorBinding =
CONST_EXPR(new Binding(NgValidator, {toAlias: forwardRef(() => CreditCardValidator)}));
@Directive({selector: '[credit-card]', hostInjector: [creditCardValidatorBinding]})
@Directive({selector: '[credit-card]', bindings: [creditCardValidatorBinding]})
class CreditCardValidator {
get validator() { return CreditCardValidator.validate; }

View File

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

View File

@ -31,7 +31,7 @@ class RedDec {
selector: 'hello-app',
// These are services that would be created if a class in the component's
// template tries to inject them.
viewInjector: [GreetingService]
viewBindings: [GreetingService]
})
// The template for the component.
@View({