I am having a weird issue with location.path(),as I don't get redirected to the page I want. I have a link in my HTML file as follow:
<a title="{{woa.name}}" href="#/" ng-right-click="" href="javascript:void(0)" ng-click="goToDetailPage(woa.pk,'workofart')">
The corresponding controller has the following code:
appTreasure.controller("mySecondController", function($scope, $http, $location) {
$scope.goToDetailPage = function(pk, selectedDetailsPage) {
newLocation = selectedDetailsPage + '/' + pk;
console.log("NEW: " + newLocation);
$location.path(newLocation);
}
// some more unrelated code
The current URL is: <base>/#/beinspiredby
and the printed newLocation is something like <base>/#/workofart/someexistingpk
. So, I am building the new location with valid values.
Unfortunately, when I click on the link, I get redirected to <base>/#/
.
If I manually go to <base>/#/workofart/someexistingpk
I correctly land to the page I am looking for.
Furthermore, in a third controller, I have exactly the same code for goToDetailPage
and it works.
Where am I missing something?