bind-query-params
bind-query-params copied to clipboard
Update the form when the queryParams are updated
I'm submitting a...
[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report
[ ] Performance issue
[x] Feature request
[ ] Documentation issue or request
[ ] Support request
[ ] Other... Please describe:
Current behavior
When updating the queryParams of a component via this.router.navigate([], { queryParams: { search: 'b' } });
, the formControl search
is not updated.
Expected behavior
The formControl search
should be updated with the value b
Minimal reproduction of the problem with instructions
https://stackblitz.com/edit/stackblitz-starters-3f5dsm?file=src%2Fapp%2Fapp.component.ts
What is the motivation / use case for changing the behavior?
When navigating through the app, inputs should match the queryParams even if the component is reused. The binding should be "bi-directional". The only way to achieve this is to completely destroy the component or manually listen to queryParams and update the form.
I can eventually do the PR, do not hesitate if you have any ideas on how to implement it.
@shaharkazaz can you take this discussion?