本文介绍了检索网址最后号码JSON - angularjs应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个angularjs应用程序,数据加载从这个JSON文件:

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

<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>

然而,在code的这一部分:&LT; TD&GT;&LT; A HREF =#/团队/ {{team._links.team.href}}&GT; ,加载在URL如。 我想检索在结束最后一个数字,它们可以是取代的整个URL大于2或小于更长。所以之后,最后的/什么,有没有一种方法,我能做到这一点?

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?

推荐答案

看起来像要编写这样一个过滤器:

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}}">

这篇关于检索网址最后号码JSON - angularjs应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-03 03:04