Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Angular 6 + AOT + lazy-loaded: Dependency injection fails #123

Closed
guillaumegarcia13 opened this issue May 30, 2018 · 4 comments
Closed

Angular 6 + AOT + lazy-loaded: Dependency injection fails #123

guillaumegarcia13 opened this issue May 30, 2018 · 4 comments
Labels

Comments

@guillaumegarcia13
Copy link

guillaumegarcia13 commented May 30, 2018

I recently migrated to Angular 6 and when AOT-compiling a lazy-loaded module which imports ArchwizardModule, the dependecy injection fails, meaning:

@ViewChild(WizardComponent) public wizard: WizardComponent;

and then calling

this.wizard.navigation.goToNextStep();

it fails because this.wizard is undefined.

I usually use this to programmatically change the step of the wizard.
Nonetheless, if I use the more simple approach with awNextStep directive, it works as expected.

Thanks in advance for your insights!

@madoar
Copy link
Owner

madoar commented Jun 5, 2018

This seems to be the same issue as in #116.

The issue seems to be that @ViewChild doesn't seem to do its job in this case as intended.
Can you check, if @ViewChild works, when used with other libraries?

@madoar madoar added the bug label Jun 5, 2018
@guillaumegarcia13
Copy link
Author

Indeed!
I'm closing this one then as it is a duplicate.

@maxisacoder
Copy link

@madoar have you got some ideas that why can not inject like this in AOT?

@madoar
Copy link
Owner

madoar commented Jun 12, 2018

No currently I have no idea.
The problem on my side is, that I'm not facing this error, which makes it hard for me to debug.

The interesting thing is, that you receive no error (exception) message, just an undefined value when you access the injected object.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants