I'm working on a function for handling multiple parameters in the URL when clicking an element. Specifically, I need to check if parameter pthree exists, update it to a new value without duplicating, and if it doesn't exist, append it to the current URL before reloading the page.
However, I've hit a roadblock trying to update the URL effectively.
This is my current URL structure:
mypage?pone=99.9999999&ptwo=-44.4444444&pthree=1&pfour=1&pfive=1
Snippet of my controller:
$scope.test = function (){
$location.search('pthree', 0);
}
The issue with this code is that while it does update the URL, it appends #?pthree=0 to the end of the current URL instead of updating the existing parameter directly.
What I actually want is:
mypage?pone=99.9999999&ptwo=-44.4444444&pthree=0&pfour=1&pfive=1
If anyone has any suggestions on achieving this desired result, I would greatly appreciate it. Thank you!