8

I wan't to open the following url from my controller /plant/needs/temperatures?open=temperatures, where the parameter open=temperatures is there to ask the page to open the related popup with the code as follows:

$scope.openPageUrl = function (url) {
    closePopover();
    console.log("Open page url "+url);
    $location.path(url);
};

<a ng-click="openPageUrl('/plant/needs/temperatures?open=temperatures')">Click to open</a>

Unfortunately, I've got this url #/plant/needs/temperatures%3Fopen=temperatures requested, with the question mark replaced by %3F, preventing the page to open.

Any idea to fix this?

Stéphane de Luca
  • 12,745
  • 9
  • 57
  • 95

1 Answers1

14

If you try to get the current path using $location.path it will return path without query strings because $location.path don't understand them. So that's why it encodes it when appending new path.

You should use $location.url which won't encode ?. Because it handles the changes of .path, .search and .hash

$location.url(url);
Rahil Wazir
  • 10,007
  • 11
  • 42
  • 64