Get query parameters in App module

in child components I can use the activate(params){...} method to get hold of an object representing the parsed query parameters.

however, if I try the same method in the root component (App), params is always undefined.

I can access the URL via location.href, and manipulate it to get the parameter that I want.

but is there a cleaner way of achieving the behavior of the child, also in the App component?

1 Like

I’m not sure, but I think the router is responsible for injecting that stuff in activate() and at that stage the router isn’t initialized so the activate() behavior is different there. I’m even questioning the point of the activate() method at that stage if what I’m saying is correct.

That being said, have you tried using the underlying route-recogniser lib Aurelia uses directly? It should give you the same object when invoking it’s parse methods.


looking further, you might even get what you want using yet another aurelia lib the route-recogniser references


@arnederuwe thanks a lot. I’ll give it a try.
those modules are available in a standard CLI project? I’ve never heard of them.

1 Like

They should be, as the router directly references both of the libraries I mentioned