javascript - Prevent route interpretation when adding parameters to URL -
in angularjs application have following routing mechanism:
$routeprovider.when('/questions', route.resolve('questions', 'questions/', 'questions', 'overview', access.authorizedaccess))
this works correctly, hitting url domain.com/app/#/questions
loading correct controller , template.
what want have option add parameters current url without triggering page reload (basically reinterpreting url). problem have doing window.location.hash = '#/questions?query=test';
route reinterpreted causing page reload.
what have tried this:
$rootscope.$on("$locationchangestart", function (event, next, current) { if (next.indexof('?') > -1) event.preventdefault(); });
this indeed not trigger route reinterpretation, removes parameter hash, turning '/questions'
.
can try option reloadonsearch:false
during intitializing routes in $routeprovider
. see documentation here
Comments
Post a Comment