user2908112
user2908112

Reputation: 535

Angularjs-route href not evaluated

When I try to route from /players to /players/:playerId in my Angularjs-porject the URL updates to players#/players/4173 and not to the desired players/4173. This is the href:

<a href="#/players/4173">playerName</a>

and this is the route config:

when('/players/:playerId', {
      template: '<player-detail></player-detail>'
    })

I can manually type .../players/4173 and it works, but when clicking it does not work and I see the URL

.../players#%2Fplayers%2F4173

What's wrong?

NOTE: The live code from Angularjs own tutorial has the same error in my browser:

http://angular.github.io/angular-phonecat/step-8/app/

SOLVED:

/#!/players/playerId

They missed that (#!) in the early example code of the tutorial I followed.

Upvotes: 1

Views: 792

Answers (3)

Yosvel Quintero
Yosvel Quintero

Reputation: 19060

When you now navigate to /index.html, you are redirected to /index.html#!/players than your links should look like this:

<a href="#!/players/4173">playerName</a>

Upvotes: 1

Gayathri Mohan
Gayathri Mohan

Reputation: 2962

Hi change your a tag like this

  <a class="pointer" ng-click="players(4173)" > 

JS

$scope.players = function(_data){
        $state.go('players',{'playersid':_data});
    }

config.js

.state('players', {
            url: '/players?playersid',
            templateUrl: 'views/xxgg/timeline.html',
            controller: 'campaignTimeline',
            params: {
                 'playersid': null
             }

        })

Upvotes: 0

DzungPT
DzungPT

Reputation: 1

I think you should remove "players/" part in your URL and see if it works. Currently it is duplicated.

Upvotes: 0

Related Questions