0

I have an angularjs app that loads in data from this JSON file:

http://www.football-data.org/alpha/soccerseasons/354/leagueTable?callback=JSON_CALLBACK

<tr ng-repeat="team in teamsList">
        <td>{{$index + 1}}</td>

        <td><a href="#/teams/{{team._links.team.href}}">
              {{team.teamName}}
              </a></td>
        <td>{{team.playedGames}}</td>
        <td>{{team.points}}</td>
        <td>{{team.goals}}</td>
        <td>{{team.goalsAgainst}}</td>
        <td>{{team.goalDifference}}</td>
      </tr>

However in this part of the code: <td><a href="#/teams/{{team._links.team.href}}"> which loads in URL eg. http://api.football-data.org/alpha/teams/61 I want to retrieve the last numbers at the end, they could be longer than 2 or less, instead of the whole URL. So anything after that last /, is there a way I could do this?

1 Answer 1

0

Looks like you want to write a filter like this one: Substring in Angularjs using filters?

If it's always two digits, you could get away with this:

<a href="#/teams/{{team._links.team.href|limitTo:-2}}">
Sign up to request clarification or add additional context in comments.

2 Comments

thanks, the only snag is that it could be 1, 2 or 3 digits long. Any idea to make sure it will always capture them?
Looks like you will have to either write a filter function or process teamsList into a new list in your controller (extracting the team id).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.