@@ -660,6 +660,37 @@ export class Directive extends Injectable {
660660 //TODO(vsavkin): This would better fall under the Macro directive concept.
661661 compileChildren : boolean ;
662662
663+ /**
664+ * Defines the set of injectable objects that are visible to a Directive and its light dom children.
665+ *
666+ * ## Simple Example
667+ *
668+ * Here is an example of a class that can be injected:
669+ *
670+ * ```
671+ * class Greeter {
672+ * greet(name:string) {
673+ * return 'Hello ' + name + '!';
674+ * }
675+ * }
676+ *
677+ * @Directive ({
678+ * selector: 'greet',
679+ * hostInjector: [
680+ * Greeter
681+ * ]
682+ * })
683+ * class HelloWorld {
684+ * greeter:Greeter;
685+ *
686+ * constructor(greeter:Greeter) {
687+ * this.greeter = greeter;
688+ * }
689+ * }
690+ * ```
691+ */
692+ hostInjector :List ;
693+
663694 @CONST ( )
664695 constructor ( {
665696 selector,
@@ -670,6 +701,7 @@ export class Directive extends Injectable {
670701 hostAttributes,
671702 hostActions,
672703 lifecycle,
704+ hostInjector,
673705 compileChildren = true ,
674706 } :{
675707 selector :string ,
@@ -680,6 +712,7 @@ export class Directive extends Injectable {
680712 hostAttributes : any ,
681713 hostActions : any ,
682714 lifecycle :List ,
715+ hostInjector :List ,
683716 compileChildren :boolean
684717 } = { } )
685718 {
@@ -693,6 +726,7 @@ export class Directive extends Injectable {
693726 this . hostActions = hostActions ;
694727 this . lifecycle = lifecycle ;
695728 this . compileChildren = compileChildren ;
729+ this . hostInjector = hostInjector ;
696730 }
697731
698732 /**
@@ -845,6 +879,48 @@ export class Component extends Directive {
845879 */
846880 appInjector :List ;
847881
882+ /**
883+ * Defines the set of injectable objects that are visible to its view dom children.
884+ *
885+ * ## Simple Example
886+ *
887+ * Here is an example of a class that can be injected:
888+ *
889+ * ```
890+ * class Greeter {
891+ * greet(name:string) {
892+ * return 'Hello ' + name + '!';
893+ * }
894+ * }
895+ *
896+ * @Directive ({
897+ * selector: 'needs-greeter'
898+ * })
899+ * class NeedsGreeter {
900+ * greeter:Greeter;
901+ *
902+ * constructor(greeter:Greeter) {
903+ * this.greeter = greeter;
904+ * }
905+ * }
906+ *
907+ * @Component ({
908+ * selector: 'greet',
909+ * viewInjector: [
910+ * Greeter
911+ * ]
912+ * })
913+ * @View ({
914+ * template: `<needs-greeter></needs-greeter>`,
915+ * directives: [NeedsGreeter]
916+ * })
917+ * class HelloWorld {
918+ * }
919+ *
920+ * ```
921+ */
922+ viewInjector :List ;
923+
848924 @CONST ( )
849925 constructor ( {
850926 selector,
@@ -856,6 +932,8 @@ export class Component extends Directive {
856932 hostActions,
857933 appInjector,
858934 lifecycle,
935+ hostInjector,
936+ viewInjector,
859937 changeDetection = DEFAULT ,
860938 compileChildren = true
861939 } :{
@@ -868,6 +946,8 @@ export class Component extends Directive {
868946 hostActions :any ,
869947 appInjector :List ,
870948 lifecycle :List ,
949+ hostInjector :List ,
950+ viewInjector :List ,
871951 changeDetection :string ,
872952 compileChildren :boolean
873953 } = { } )
@@ -880,12 +960,14 @@ export class Component extends Directive {
880960 hostProperties : hostProperties ,
881961 hostAttributes : hostAttributes ,
882962 hostActions : hostActions ,
963+ hostInjector : hostInjector ,
883964 lifecycle : lifecycle ,
884965 compileChildren : compileChildren
885966 } ) ;
886967
887968 this . changeDetection = changeDetection ;
888969 this . appInjector = appInjector ;
970+ this . viewInjector = viewInjector ;
889971 }
890972}
891973
0 commit comments