Created
January 17, 2022 04:16
-
-
Save michaelmcshinsky/72d2f1ed7f0ee8d251a60073d5fdb242 to your computer and use it in GitHub Desktop.
Change AngularJS navigation route without reload
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
angular | |
.module('app', []) | |
.config([]) | |
.run(['$location', '$route'], function () { | |
const original = $location.path; | |
$location.path = function (path, reload) { | |
if (reload === false) { | |
const lastRoute = $route.current; | |
const un = $rootScope.$on('$locationChangeSuccess', () => { | |
$route.current = lastRoute; | |
un(); | |
}); | |
} | |
return original.apply($location, [path]); | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment