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?

2
  • Duplicate? stackoverflow.com/questions/19359553/… Commented Apr 2, 2015 at 22:11
  • I am not working outside Angular nor am I adding an event listener. Why should it be a duplicate? Commented Apr 2, 2015 at 22:16

1 Answer 1

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')">
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks. Actually it is enough to drop href="#/", which was an old thing.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.