Repository navigation
canMatch check throws NullInjectorError for a guard provided at the route level #46386
Description
Activity
- changed the title
[-]`canMatch` check throws `NullInjectorError` for a provider defined at the route level[/-][+]`canMatch` check throws `NullInjectorError` for a guard provided at the route level[/+]on Jun 16, 2022 This is a side-effect of #45990 to address #45988. This would likely need to be addressed through a documentation update, as your expectation is incompatible with the expectation that was raised in #45988.
The PR for
CanMatchwas started before theproviderswere added to theRoute. This should actually work but I performed the rebase incorrectly. We can create the injector after a route matches via thepathormatchproperties and before running thecanMatchguards. This should still work as expected with respect to #45988.Reacted by Joost Koehoorn and Marko Stanimirović- added a commit that references this issue
on Jun 16, 2022 - addedP3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentAn issue that is relevant to core functions, but does not impede progress. Important, but not urgent
on Jun 16, 2022 angular-automatic-lock-bot commented
on Jul 18, 2022 More actionsThis 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.
- locked and limited conversation to collaborators
on Jul 18, 2022
Which @angular/* package(s) are the source of the bug?
router
Is this a regression?
No
Description
There is the
NullInjectorErrorif we try to use theCanMatchguard that is provided at the route level:If we try to use e.g.
CanActivateguard that is provided at the route level, it will be properly injected:Please provide a link to a minimal reproduction of the bug
No response
Please provide the exception or error you saw
Please provide the environment you discovered this bug in (run
ng version)Anything else?
No response