In addition to renaming this, I think we should consider allowing appInjector to take not only string-based ng1 injectables (e.g. '$http') but also a1atscript created injectables (e.g. Greeter).
We have to add the Greeter service as a module dependency on the Greet component's module. Then also add it to injectables. Seems like we could reduce some boilerplate here.
In this example I've renamed injectables to appInjector but I've now added the ability to not only inject string-based things like '$http' but also the Greeter service. This more closely matches how ng2 uses classes instead of strings. Also, notice I left out the @AsModule because it should be able to grab the module off of the Greeter class passed into the appInjector.
So the acceptance criteria for this feature would be:
Rename injectables to appInjector
Allow passing a1atscript class-based injectables in addition to string-based regular ng1 injectables
Add the modules from a1atscript classes in appInjector to the dependencies of the auto-generated module of the host class.
If @AsModule is present then merge the dependencies, also allow @AsModule to only specify a name and no dependencies, e.g. @AsModule("GreetComponent")
The latest Angular 2 has renamed
injectables
toappInjector
. See: https://angular.io/docs/js/latest/api/annotations/ComponentAnnotation-class.html.In addition to renaming this, I think we should consider allowing
appInjector
to take not only string-based ng1 injectables (e.g.'$http'
) but also a1atscript created injectables (e.g.Greeter
).For example, currently we do this:
We have to add the Greeter service as a module dependency on the Greet component's module. Then also add it to
injectables
. Seems like we could reduce some boilerplate here.We should be able to do this:
In this example I've renamed
injectables
toappInjector
but I've now added the ability to not only inject string-based things like'$http'
but also the Greeter service. This more closely matches how ng2 uses classes instead of strings. Also, notice I left out the @AsModule because it should be able to grab the module off of the Greeter class passed into theappInjector
.So the acceptance criteria for this feature would be:
injectables
toappInjector
appInjector
to the dependencies of the auto-generated module of the host class.@AsModule("GreetComponent")