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

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -