javascript - how to pass the query parameter with the othwerwise function -
given following javascript:
$stateprovider .state('search', { url: '/search?query', }) ; $urlrouterprovider.otherwise("search");
when access page
base_url?query=x
i redirected
base_url/search
but query parameter gets lost.
is there way pass query parameter otherwise function?
there a working plunker
the ui-router has native solution here.
the
otherwise
not have "url" string, function.
check in action in q & a:
how not change url when show 404 error page ui-router
the code this:
$urlrouterprovider.otherwise(function($injector, $location){ var state = $injector.get('$state'); state.go("search", $location.search()); // here { query: ... } return $location.path(); });
the $location.search()
give params object, like: { query: ... }
. take , redirect state search params...
check here
Comments
Post a Comment