- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-18-2017 04:13 PM
Has anyone figured out how to change the URL without reloading the page?
I would like to alter the URL so that my users can send it out and it will pre-populate widget information. Problem is that it reloads. I have tried to figure out how to use ngRoute, ui.route, and history.pushState. All seem to reload the page. Any other thoughts?
Thanks!
Solved! Go to Solution.
- Labels:
-
Service Portal Development

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-23-2017 04:27 AM
You are right, it seems like that the reason for this is that the $locationChangeStart events gets triggered more than once so you have to build a condition within the event listener.
What has worked for me is the following:
The event listener:
var originalUrl, initUrl;
$rootScope.$on("$locationChangeStart", function(e, newUrl){
if(newUrl != originalUrl && newUrl != initUrl){
$window.history.replaceState(newUrl, $document.title, newUrl);
}
originalUrl = newUrl;
e.preventDefault();
});
The URL change:
$scope.changeURL = function(){
initUrl = $location.absUrl();
//Set your desired URL parameters here, you could also extend the current ones with:
/*
var params = $location.search()
angular.extend(params, {
someParam:'test'
});
*/
var params = {
someParam:'test',
anotherParam:'anotherTest'
};
//triggers the $locationChangeStart event
$location.search($httpParamSerializer(params));
}
Dont forget to inject $document, $httpParamSerializer, $location, $scope and $rootScope in your controller.
Let me know if this worked out for you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-18-2017 10:14 PM
Hi Amanda,
Can be more specific? Do you need to share the URL of a record to other users? I couldn't quite get what you mean by pre-populate widget information?
Darshak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-19-2017 07:21 AM
Basically I want to change the URL without reloading the page. I haven't found a way of doing that yet within Service Portal.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-19-2017 07:24 AM
Hi Amanda,
Do you want set the URL dynamically for specific link . Can you provide more details.
Regards,
Harish Murikinati.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-19-2017 07:37 AM
Basically, I have a page where you select something to search, search for an item, then can view details of that item. Along that process, I want to put the selections into the URL so that a user can send the URL to another colleague to view, and that person won't have to do the search themselves.
Think of it like filtering on SN tables. It throws your search info into the URL so you can use the URL to get back where you are. That's what I am looking to do, but I do not want the page to refresh every time I alter the URL.