Angular $location search does not work always

I'm having a problem I can't seem to understand why it is happening:

I have an angular app where one of the routes is defined in the route provider as

 .when('/pageA/:item1', {templateUrl:xxx, reloadOnSearch:false})

I have a service function which in turn is using the following code:

var targetUrl = '/pageA/'+item1;
$location.path(targetUrl).search('item2',item2Val);

The problem is that if the user is at a page with a location different than pageA, the url is correct and I Can see both values, item1 and item2. However, if the user is already at pageA and there iis only a change in item1 and item2, the resulting url does not include the search object item2.

Can anyone explain this ?

Thanks.


ANSWERS:


if you want to catch the change in url, even in the same page, set reloadOnSearch to true



 MORE:


 ? Can we pass two parameters in $routeProvider.when() function in angular js
 ? Angular 1.x/2 Hybrid, karma tests not bootstrapping ng1 app
 ? Node server to intercept all request from angular (http) to java spring backend
 ? Angular change url without executing routeprovider
 ? Angular js - call a route without view
 ? .config $routeprovider angularjs
 ? Angular JS not loading view
 ? AngularJS directive vs routeProvider
 ? controller not found through routeProvider
 ? routeProvider not working correctly