Turn off URL manipulation in AngularJS
Not sure of the side effects of this, but it gets the job done. Note that it will disable all location manipulation from the angular app, even if intended.
angular.module('sample', [])
.config( ['$provide', function ($provide){
$provide.decorator('$browser', ['$delegate', function ($delegate) {
$delegate.onUrlChange = function () {};
$delegate.url = function () { return ""};
return $delegate;
}]);
}]);
ES6 variant:
angular.module('sample', [])
.config(["$provide", $provide => {
$provide.decorator("$browser", ["$delegate", $delegate => {
$delegate.onUrlChange = () => { };
$delegate.url = () => "";
return $delegate;
}]);
}]);
Tested in Chrome 30, IE9, IE10.
Inspired by https://stackoverflow.com/a/16678065/369724
I use a local copy of angular.js. Search for
$browser.onUrlChange(function(newUrl, newState) {
and
$rootScope.$watch(function $locationWatch() {
comment out the corresponding lines and angularjs will stop watch for location url changes.