Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

$location changes the ? parameter delimiter

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?

like image 667
Stéphane de Luca Avatar asked Jul 15 '14 17:07

Stéphane de Luca


1 Answers

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);
like image 163
Rahil Wazir Avatar answered Oct 15 '22 20:10

Rahil Wazir