Skip to content

Commit 7b51146

Browse files
committed
refactor(core): renamed injectables into appInjector
BREAKING CHANGES Before: @component({injectables: [Type]} class MyCmp{} After: @component({appInjector: [Type]} class MyCmp{}
1 parent 3a53f67 commit 7b51146

File tree

17 files changed

+34
-52
lines changed

17 files changed

+34
-52
lines changed

modules/angular2/docs/core/02_directives.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ To better understand the kinds of injections which are supported in Angular we h
216216

217217
### Injecting Services
218218

219-
Service injection is the most straight forward kind of injection which Angular supports. It involves a component configuring the `injectables` and then letting the directive ask for the configured service.
219+
Service injection is the most straight forward kind of injection which Angular supports. It involves a component configuring the `appInjector` and then letting the directive ask for the configured service.
220220

221221
This example illustrates how to inject `MyService` into `House` directive.
222222

@@ -227,7 +227,7 @@ class MyService {} | Assume a service which needs to be inject
227227
|
228228
@Component({ | Assume a top level application component which
229229
selector: 'my-app', | configures the services to be injected.
230-
injectables: [MyService] |
230+
appInjector: [MyService] |
231231
}) |
232232
@View({ | Assume we have a template that needs to be
233233
templateUrl: 'my_app.html', | configured with directives to be injected.
@@ -330,7 +330,7 @@ Shadow DOM provides an encapsulation for components, so as a general rule it doe
330330
```
331331
@Component({
332332
selector: '[kid]',
333-
injectables: []
333+
appInjector: []
334334
})
335335
@View({
336336
templateUrl: 'kid.html',
@@ -349,7 +349,7 @@ class Kid {
349349
350350
@Component({
351351
selector: '[dad]',
352-
injectables: [Grandpa]
352+
appInjector: [Grandpa]
353353
})
354354
@View({
355355
templateUrl: 'dad.html',
@@ -364,7 +364,7 @@ class Dad {
364364
365365
@Component({
366366
selector: '[grandpa]',
367-
injectables: []
367+
appInjector: []
368368
})
369369
@View({
370370
templateUrl: 'grandpa.html',

modules/angular2/src/core/annotations_impl/annotations.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,7 @@ export class Directive extends Injectable {
714714
* When a component is instantiated, Angular
715715
* - creates a shadow DOM for the component.
716716
* - loads the selected template into the shadow DOM.
717-
* - creates a child {@link Injector} which is configured with the `injectables` for the {@link Component}.
717+
* - creates a child {@link Injector} which is configured with the `appInjector` for the {@link Component}.
718718
*
719719
* All template expressions and statements are then evaluated against the component instance.
720720
*
@@ -800,16 +800,16 @@ export class Component extends Directive {
800800
/**
801801
* Defines the set of injectable objects that are visible to a Component and its children.
802802
*
803-
* The `injectables` defined in the Component annotation allow you to configure a set of bindings for the component's
803+
* The `appInjector` defined in the Component annotation allow you to configure a set of bindings for the component's
804804
* injector.
805805
*
806806
* When a component is instantiated, Angular creates a new child Injector, which is configured with the bindings in
807-
* the Component `injectables` annotation. The injectable objects then become available for injection to the component
807+
* the Component `appInjector` annotation. The injectable objects then become available for injection to the component
808808
* itself and any of the directives in the component's template, i.e. they are not available to the directives which
809809
* are children in the component's light DOM.
810810
*
811811
*
812-
* The syntax for configuring the `injectables` injectable is identical to {@link Injector} injectable configuration.
812+
* The syntax for configuring the `appInjector` injectable is identical to {@link Injector} injectable configuration.
813813
* See {@link Injector} for additional detail.
814814
*
815815
*
@@ -826,7 +826,7 @@ export class Component extends Directive {
826826
*
827827
* @Component({
828828
* selector: 'greet',
829-
* injectables: [
829+
* appInjector: [
830830
* Greeter
831831
* ]
832832
* })
@@ -843,7 +843,7 @@ export class Component extends Directive {
843843
* }
844844
* ```
845845
*/
846-
injectables:List;
846+
appInjector:List;
847847

848848
@CONST()
849849
constructor({
@@ -854,7 +854,7 @@ export class Component extends Directive {
854854
hostProperties,
855855
hostAttributes,
856856
hostActions,
857-
injectables,
857+
appInjector,
858858
lifecycle,
859859
changeDetection = DEFAULT,
860860
compileChildren = true
@@ -866,7 +866,7 @@ export class Component extends Directive {
866866
hostProperties:any,
867867
hostAttributes:any,
868868
hostActions:any,
869-
injectables:List,
869+
appInjector:List,
870870
lifecycle:List,
871871
changeDetection:string,
872872
compileChildren:boolean
@@ -885,7 +885,7 @@ export class Component extends Directive {
885885
});
886886

887887
this.changeDetection = changeDetection;
888-
this.injectables = injectables;
888+
this.appInjector = appInjector;
889889
}
890890
}
891891

modules/angular2/src/core/application.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ function _createNgZone(givenReporter:Function): NgZone {
184184
* 1. It uses the component's `selector` property to locate the DOM element which needs to be upgraded into
185185
* the angular component.
186186
* 2. It creates a new child injector (from the platform injector) and configures the injector with the component's
187-
* `injectables`. Optionally, you can also override the injector configuration for an app by invoking
187+
* `appInjector`. Optionally, you can also override the injector configuration for an app by invoking
188188
* `bootstrap` with the `componentInjectableBindings` argument.
189189
* 3. It creates a new `Zone` and connects it to the angular application's change detection domain instance.
190190
* 4. It creates a shadow DOM on the selected component's host element and loads the template into it.
@@ -227,7 +227,7 @@ function _createNgZone(givenReporter:Function): NgZone {
227227
* # API
228228
* - `appComponentType`: The root component which should act as the application. This is a reference to a `Type`
229229
* which is annotated with `@Component(...)`.
230-
* - `componentInjectableBindings`: An additional set of bindings that can be added to `injectables` for the
230+
* - `componentInjectableBindings`: An additional set of bindings that can be added to `appInjector` for the
231231
* {@link Component} to override default injection behavior.
232232
* - `errorReporter`: `function(exception:any, stackTrace:string)` a default error reporter for unhandled exceptions.
233233
*

modules/angular2/src/core/compiler/element_injector.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,8 @@ export class DirectiveBinding extends ResolvedBinding {
279279
var changeDetection = null;
280280
if (ann instanceof Component) {
281281
renderType = DirectiveMetadata.COMPONENT_TYPE;
282-
if (isPresent(ann.injectables)) {
283-
resolvedInjectables = Injector.resolve(ann.injectables);
282+
if (isPresent(ann.appInjector)) {
283+
resolvedInjectables = Injector.resolve(ann.appInjector);
284284
}
285285
changeDetection = ann.changeDetection;
286286
} else {

modules/angular2/src/core/exception_handler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {DOM} from 'angular2/src/dom/dom_adapter';
1414
* ```javascript
1515
* @Component({
1616
* selector: 'my-app',
17-
* injectables: [
17+
* appInjector: [
1818
* bind(ExceptionHandler).toClass(MyExceptionHandler)
1919
* ]
2020
* })

modules/angular2/src/forms/form_builder.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import * as modelModule from './model';
1414
*
1515
* @Component({
1616
* selector: 'login-comp',
17-
* injectables: [
17+
* appInjector: [
1818
* FormBuilder
1919
* ]
2020
* })

modules/angular2/test/core/compiler/dynamic_component_loader_spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ class DynamicComp {
279279

280280
@Component({
281281
selector: 'hello-cmp',
282-
injectables: [DynamicallyCreatedComponentService]
282+
appInjector: [DynamicallyCreatedComponentService]
283283
})
284284
@View({
285285
template: "{{greeting}}"

modules/angular2/test/core/compiler/element_injector_spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ export function main() {
516516

517517
it("should instantiate component directives that depend on app services in the shadow app injector", () => {
518518
var directiveAnnotation = new Component({
519-
injectables: [
519+
appInjector: [
520520
bind("service").toValue("service")
521521
]
522522
});
@@ -531,7 +531,7 @@ export function main() {
531531

532532
it("should not instantiate other directives that depend on app services in the shadow app injector", () => {
533533
var directiveAnnotation = new Component({
534-
injectables: [
534+
appInjector: [
535535
bind("service").toValue("service")
536536
]
537537
});

modules/angular2/test/core/compiler/integration_dart_spec.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ void functionThatThrows() {
2121

2222
main() {
2323
describe('TypeLiteral', () {
24-
it('should publish via injectables',
24+
it('should publish via appInjector',
2525
inject([TestBed, AsyncTestCompleter], (tb, async) {
2626
tb.overrideView(Dummy, new View(
2727
template: '<type-literal-component></type-literal-component>',
@@ -57,7 +57,7 @@ class Dummy {}
5757

5858
@Component(
5959
selector: 'type-literal-component',
60-
injectables: const [
60+
appInjector: const [
6161
const Binding(
6262
const TypeLiteral<List<String>>(),
6363
toValue: const <String>['Hello', 'World'])

modules/angular2/test/core/compiler/integration_spec.js

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import {PipeRegistry, defaultPipeRegistry,
2727
ChangeDetection, DynamicChangeDetection, Pipe, ChangeDetectorRef, ON_PUSH} from 'angular2/change_detection';
2828

2929
import {Directive, Component} from 'angular2/src/core/annotations_impl/annotations';
30-
import {DynamicComponentLoader} from 'angular2/src/core/compiler/dynamic_component_loader';
3130
import {QueryList} from 'angular2/src/core/compiler/query_list';
3231
import {View} from 'angular2/src/core/annotations_impl/view';
3332
import {Parent, Ancestor} from 'angular2/src/core/annotations_impl/visibility';
@@ -1112,7 +1111,7 @@ class ComponentWithPipes {
11121111

11131112
@Component({
11141113
selector: 'child-cmp',
1115-
injectables: [MyService],
1114+
appInjector: [MyService],
11161115
})
11171116
@View({
11181117
directives: [MyDir],
@@ -1177,7 +1176,7 @@ class CompWithAncestor {
11771176

11781177
@Component({
11791178
selector: '[child-cmp2]',
1180-
injectables: [MyService]
1179+
appInjector: [MyService]
11811180
})
11821181
class ChildComp2 {
11831182
ctxProp:string;
@@ -1414,23 +1413,6 @@ class NeedsPublicApi {
14141413
}
14151414
}
14161415

1417-
@Component({
1418-
selector: 'child',
1419-
injectables: [AppDependency]
1420-
})
1421-
@View({
1422-
template: `<div>{{parent.message}}</div>,<div>{{appDependency.parent.message}}</div>`
1423-
})
1424-
class ChildComponent {
1425-
parent:ParentInterface;
1426-
appDependency:AppDependency;
1427-
1428-
constructor(p:ParentInterface, a:AppDependency) {
1429-
this.parent = p;
1430-
this.appDependency = a;
1431-
}
1432-
}
1433-
14341416
@Directive({
14351417
selector: '[toolbar-vc]',
14361418
properties: {

0 commit comments

Comments
 (0)