In our Angular App we have a DropDown component which is populated with years.
Once we select an year, we need to change the router url, to be something like:
url/customers/2015
url/customers/2016
url/customers/2017
OR
url/customers/some-other-page/2015
url/customers/some-other-page/2016
url/customers/some-other-page/2017
This works, but we delegate the change event of the dropdown to the components that need it. That is fine!
BUT we thoughtit would make our life easier, if the component makes the route change by itself.
We tried:
public onChange(year): void {
this.router.([this.router.url, year]);
}
This works only in the first time, the second time the url looks like this:
url/customers/some-other-page/2017/2018
The third time:
url/customers/some-other-page/2017/2018/2019
and so on...
Question:
So, how do I get the parameter of my router and replace it with the current paremeter?