Open drarmstr opened 9 years ago
You can do that with onUrlChange="updateModel"
!
https://erikringsmuth.github.io/app-router/#/api#onurlchange
<app-router>
<app-route path="/user/:userId/**" element="user-page" onUrlChange="updateModel"></app-route>
</app-router>
Ah, thank you! I missed the link to the documentation from the GitHub page and was just working off readme.md
Actually, I am seeing an issue where if the URL is updated to remove a hash path query parameter then the corresponding data binding is not updated by setting the property to undefined. Instead, it retains its previous value.
e.g., going from: http://server.com/path/path?server=blarg#route?param=foo to: http://server.com/path/path?server=blarg#route
I see where the problem is but I'm not sure how to fix this one. Updating the model happens here https://github.com/erikringsmuth/app-router/blob/master/src/app-router.js#L266. The problem is setObjectProperties()
only sets properties in the new model and doesn't know how to delete/undefine properties from the old model. The tricky part is the existing model is all mixed in with the custom element's properties.
I guess keep a map of current known parameters and if any disappear then delete them?
On May 25, 2015, at 19:11, Erik Ringsmuth notifications@github.com wrote:
I see where the problem is but I'm not sure how to fix this one. Updating the model happens here https://github.com/erikringsmuth/app-router/blob/master/src/app-router.js#L266. The problem is setObjectProperties() only sets properties in the new model and doesn't know how to delete/undefine properties from the old model. The tricky part is the existing model is all mixed in with the custom element's properties.
— Reply to this email directly or view it on GitHub.
If only a query search parameter changes (either in the main URL or in the URL hash) if would be nice to have a mode which avoided recreating the models and instead just updated the data binding.
For example, going from:
http://server.com/path/path?server=blarg#route?param=foo to: http://server.com/path/path?server=blarg#route?param=bar