2

I have a controller in Angular js which gets the data based on query string.

The url is something like this

inbound-agent#/?phone=2343434

                        if ($location.search().phone) {
                            var phone = $location.search().phone;
                            //Get data
                        }

The problem is whenever I change the value of phone and press enter, the controller code doesn't execute and page is not refreshed.

However, it does executes on the second time enter is pressed. The data is refreshed. It also works fine if I press Reload after the query string is changed first time.

Can anyone tell me why is this behavior? I want to get the updated data when someone changes the query string manually and presses enter first time.

I am using Chrome 38.

Madhur Ahuja
  • 22,211
  • 14
  • 71
  • 124
  • 1
    You should probably listen on route changes as described here: http://stackoverflow.com/questions/15093916/angularjs-watch-on-location-search-doesnt-work-when-reloadonsearch-is-false (using `$scope.$on('$routeUpdate',...)` – Michael Rose Nov 16 '14 at 14:14
  • Have you tried to get it through routePrameters instead search? – Alberto León Nov 16 '14 at 14:32
  • I solved the problem. Whenever I changed query string the child controller was being called, rather than one defined at tag. – Madhur Ahuja Nov 16 '14 at 14:34

0 Answers0