My issue is closest to THIS POST. But, it'a slightly a different scenario.
SCENARIO
I have 2 pages main and detail.
- To visit the main page, I visit http://localhost:3000/main
- To visit the detail page, I visit http://localhost:3000/detail
Now, in the main page, I have a drop-down the has initially no value selected.
And, in the details page I have a BACK link that points back to main page
CODE
ROUTES
{
path: 'main',
component: SomeComponent
},
{
path: 'main/:dropdown_value',
component: SomeComponent
}
DETAIL TEMPLATE
<a [routerLink]="['/main', selectedDropDownValue]">BACK</a>
The selectedDropDownValue
comes from component and contains the dropdown's selected value from the main page.
PROBLEM
The above implementation works like charm. So, when I hit back the main page, based on the params I passed, I re-select the last selected dropdown value. But, now the main URL becomes:
http://localhost:3000/main/abc
Here, abc
is the selected dropdown value
But, I want the URL to stay like
It shouldn't show /abc at the end