You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Router: canActivateChild can't find guard provided in own module #12275
[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
Current behavior
When trying to use a children guard (canActivateChild) in the same module where the guard is provided, the guard fails to be injected.
Error: No provider for ChildGuard!
If we provide the guard in a parent module, it works.
If we provide the a canActivate guard in the same module where it is used, it works.
Expected behavior
The guard should be injected and work like the canActivate guard.
Minimal reproduction of the problem with instructions
@DzmitryShylovich The plunkr is a fork of the official demo with minimal changes (only 4 changes - see first message) in order to reproduce the problem
I created a simple setup, similar to what we use internally today. Main component provides a method to render a Type. EntryComponent is declared as entryComponent in Page1Module. However after having loaded Page1Module, when trying to render EntryComponent via ComponentFactoryResolver, No component factory found for EntryComponent is thrown.
Use-cases for this approach are:
Modals that shall be rendered in the root component
@marvinscharle the original issue was fixed. can you pls check out your issue with entry components after the next release and file a new bug if it wasn't fixed?
Activity
DzmitryShylovich commentedon Oct 13, 2016
Can u pls simplify plunkr and remove all unnecessary components/services?
pesimeao commentedon Oct 17, 2016
@DzmitryShylovich The plunkr is a fork of the official demo with minimal changes (only 4 changes - see first message) in order to reproduce the problem
vicb commentedon Dec 1, 2016
Can you please keep only what's needed to demonstrate the issue ?
pesimeao commentedon Jan 2, 2017
Hi,
Here's a new plnk that contains only the necessary information.
http://plnkr.co/edit/vc35AC1UIbZtlp0IjekX?p=preview
When you access to /admin (click on button "Go to route..."), there's an error in the console
No provider for ChildGuard!.This guard is provided in the AdminModule and used only in AdminModule.
pesimeao commentedon Jan 2, 2017
I've also updated the first post ;)
marvinscharle commentedon Jan 18, 2017
This also affects child's
entryComponents. They cannot be used outside the lazy loaded module.DzmitryShylovich commentedon Jan 20, 2017
@marvinscharle pls provide a small demo on Plunkr
marvinscharle commentedon Jan 20, 2017
@DzmitryShylovich here you go: http://plnkr.co/edit/9euisYeSNbEFrfzOhhzf?p=preview
I created a simple setup, similar to what we use internally today.
Maincomponent provides a method to render aType.EntryComponentis declared asentryComponentinPage1Module. However after having loadedPage1Module, when trying to renderEntryComponentviaComponentFactoryResolver,No component factory found for EntryComponentis thrown.Use-cases for this approach are:
by the way: thank you for the linked fixes 👍🏻
fix(router): fix CanActivateChild guard provided in a lazy loaded mod…
DzmitryShylovich commentedon Jan 31, 2017
@marvinscharle the original issue was fixed. can you pls check out your issue with entry components after the next release and file a new bug if it wasn't fixed?
fix(router): fix CanActivateChild guard provided in a lazy loaded mod…
fix(router): fix CanActivateChild guard provided in a lazy loaded mod…
angular-automatic-lock-bot commentedon Sep 10, 2019
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.