Commit Graph

5 Commits

Author SHA1 Message Date
Kara Erickson b1506a3271 fix(ivy): support injection flags for provider deps without new (#30216)
Previously, we were supporting injection flags for provider deps, but only
if they fit the format `new Optional()`. This commit fixes resolution of
provider deps to also support `Optional` (without the new). This keeps us
backwards compatible with what View Engine supported.

PR Close #30216
2019-04-30 20:37:56 -07:00
Kara Erickson 00ffc03523 fix(ivy): support forward refs in provider deps (#30201)
Currently, we are not properly resolving forward refs when they appear
in deps for providers created with the useFactory strategy. This commit
wraps provider deps in the resolveForwardRef call so the tokens are
passed into the inject function as expected.

PR Close #30201
2019-04-29 20:03:10 -07:00
Kara Erickson d9c39dcab0 fix(ivy): directiveInject should fall back to inject (#29948)
If a component has its definition set by defineComponent (as opposed to
JIT getter), then it will generate a factory that uses directiveInject()
to retrieve its dependencies. This can be problematic in test code because
tests could use the injection utility before bootstrapping the component,
and directiveInject() relies on the view having been created.

This commit tweaks directiveInject() to fall back to inject() if the view
has not been created. This will allow injection to work in tests even if
it is called before the component is bootstrapped.

PR Close #29948
2019-04-16 19:31:46 -07:00
Kara Erickson ca2462cff7 fix(ivy): support providing components and dirs in tests (#29945)
Previous to this commit, providing a component or directive in a test
module without @Injectable() would throw because the injectable factory
would not be found. Providing components in tests in addition to declaring
or importing them is not necessary, but it should not throw an error.

This commit ensures factory data is saved when component defs and directive
defs are created, which allows them to be processed by the module injector.

Note that bootstrapping is still required for this setup to work because
directiveInject() does not support cases where the view has not been
created. This case will be handled in a future commit.

PR Close #29945
2019-04-16 19:14:17 -07:00
Kristiyan Kostadinov e1aaa7ec48 fix(ivy): component destroy hook called twice when configured as provider (#28470)
Fixes the `ngOnDestroy` hook on a component or directive being called twice, if the type is also registered as a provider.

This PR resolves FW-1010.

PR Close #28470
2019-02-21 09:34:26 -08:00