Skip to content

CanMatch snapshot queryParams doesn't work #47417

@ArielGueta

Description

@ArielGueta

Which @angular/* package(s) are the source of the bug?

router

Is this a regression?

No

Description

I want a sync access to router.snapshot.queryParams in CanMatch guard and it doesn't work:

{
          path: 'todos',
          canMatch: [() => {
            // the location is todos?foo=1
            console.log(inject(ActivatedRoute).snapshot.queryParams) // { }
            return true;
          }],
}

If I wrap it with a setTimeout it logs the correct value.

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

No response

Please provide the environment you discovered this bug in (run ng version)

No response

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions