Had the very same challange,
Found a hack in another StackOverflow response that did the trick
Fairly clean solution – all I did was to add these lines to the controller that sets $location.path:
var lastRoute = $route.current;
$scope.$on('$locationChangeSuccess', function(event) {
$route.current = lastRoute;
});
..and made sure $route in injected into the controller of course.
But still, feels like “DoNotFollowRoutesOnPathChange” is a missing feature in AngularJS.
/Jens
Update: Since listening to this event effectively kills further usage of $routeProvider configs, I had to limit this catch to current path only:
var lastRoute = $route.current;
if ($route.current.$route.templateUrl.indexOf('mycurrentpath') > 0) {
$route.current = lastRoute;
}
Getting ugly…