I'd like to add one extra query parameter when clicking button and executing some code. The exact same code works fine for me when executed as part of right click menu. But when I try to do it using a button's click, it doesn't work (e.g. I can see the URL changed but after all angularjs internal code run it returns to the previous value and my extra search parameter is not appended).
This is the code I'm trying (I tried adding last line but it didn't change outcome):
addParameterToUrl(paramName, value) {
const urlParams = new URLSearchParams(window.location.search);
urlParams.set(paramName, value);
const newQuery = `${window.location.pathname}?${urlParams.toString()}`;
history.pushState(null, "", newQuery);
SW.serviceLoader.Location.path(newQuery, false);
}
Is there any way to change URL by clicking a button (input type="button")?
After reading several threads and also documentation and trying many various approaches I finally got it:
.finally(() => {
Spinner.stopSpinner("updateBooking");
this.onReload();
Timeout(() => {
this.beforeUnload();
}, 0);
});