Amit Gaikwad
Amit Gaikwad

Reputation: 923

$location.search not working if search parameters not changed

$location.search is not reloading route if search parameter are same as parameter in current location.

if window.location is "url#RouteName?param1=value1".

And in some button click calling method which has following code.

$location.path("/RouteName").search({param1 :"value1"});

Then Route is not getting reloaded, how to force reload. I have set reloadOnSeach : true in route config.

$routeProvider.when("RouteName", {templateurl:"pag1.html",controller:"MyCtrl",reloadOnSearch:truee}); 

Upvotes: 2

Views: 3102

Answers (3)

Hamza Iqbal
Hamza Iqbal

Reputation: 1

Use window.location.search instead of location.search. It will work.

Upvotes: 0

Jimmy Kane
Jimmy Kane

Reputation: 16825

Reload will realod the route.

In case you want to change the search:

$location.search({'slide_id': slide_id})

If your route params do not change (or change to the same value) then you might need to force the location change:

$scope.$emit('$locationChangeSuccess');

Upvotes: 2

doodeec
doodeec

Reputation: 2927

reloading the route is not done by $location.search explicitly, in fact it doesn't do anything if the url has not changed by the function call

use

$route.reload()

Upvotes: 3

Related Questions