0

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?

JLRishe
  • 99,490
  • 19
  • 131
  • 169
Manu
  • 4,019
  • 8
  • 50
  • 94

1 Answers1

1

I think is it because you have an href attribute in your anchor element (actually you have two).

Try this

<a title="{{woa.name}}" ng-right-click="" ng-click="goToDetailPage(woa.pk,'workofart')">
Dustin Hodges
  • 4,110
  • 3
  • 26
  • 41