Is it possible to change the location path in Angular.js without triggering the associated route. Perhaps something like the following (not working code):
$location.path("/booking/1234/", {silent: true})
You can set reloadOnSearch
to false in your router, and you can change the "search" part of the url.
The idea is that you should design your URL scheme such that if the base url changes, it represents a different resource and should reload. If the search part changes (the part after the ?
, you might just be changing a filter, or a sort order or something).
Yes it is possible using a workaround.
var off = $scope.$on('$stateChangeStart', function (e) {
e.preventDefault();
off();
});
$location.path("/booking/1234/");
The way it works is - it is caching the next state change event - make him not happen (by calling "preventDefault", and then calling itself to deregister this eventhandler).
Tested only on Chrome. Saw it in this post: https://github.com/angular-ui/ui-router/issues/64
Hope it helps
Here is the solution, compiled in angular module — https://github.com/garakh/ngSilent just add the module and then use this way:
$ngSilentLocation.silent('/new/path/');