Skip to content

Instantly share code, notes, and snippets.

@michaelmcshinsky
Created January 17, 2022 04:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaelmcshinsky/72d2f1ed7f0ee8d251a60073d5fdb242 to your computer and use it in GitHub Desktop.
Save michaelmcshinsky/72d2f1ed7f0ee8d251a60073d5fdb242 to your computer and use it in GitHub Desktop.
Change AngularJS navigation route without reload
'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