1
votes

In Aurelia, the root view-model's (app.ts, containing router config) activate(params) method doesn't receive query string parameters.

For the address: http://localhost:5000/home?param=1, the Home view-model (home.ts) is able to read query string param via activate() method, but activate() params in App view-model (app.ts) are empty.

I have router configured to use pushstate, but the behavior is the same with disabled pushshate.

Is there a way how to read query string params inside app root view-model?

1

1 Answers

3
votes

It's not going to get parameters passed to it b/c it isn't activated by the router. That being said, you can simply use VanillaJS to do this. There is a new API, that is polyfillable that you could use: https://davidwalsh.name/query-string-javascript

Remember, Aurelia is just JavaScript. This is something I say in every intro to Aurelia talk I give around the world, and it's important to take this to heart.