Javascript ng根据url重复不同的值

Javascript ng根据url重复不同的值,javascript,angularjs,arrays,angularjs-ng-repeat,Javascript,Angularjs,Arrays,Angularjs Ng Repeat,我试图根据当前url从对象数组中重复值。假设我的url是“localhost/#/scores/javelin”,我只想重复数组中的javelin分数 我的数组如下所示: $scope.ppl = [ { firstname: 'Donald', lastname: 'Trump', from: 'USA',

我试图根据当前url从对象数组中重复值。假设我的url是“localhost/#/scores/javelin”,我只想重复数组中的javelin分数

我的数组如下所示:

$scope.ppl = 
            [
                {
                    firstname: 'Donald',
                    lastname: 'Trump',
                    from: 'USA',
                    run100m: ['1s','2s','3s'],
                    javelin: ['50m','20m','44m']
                },
                {
                    firstname: 'Foo',
                    lastname: 'Bar',
                    from: 'SWE',
                    run100m: ['1s','2s','3s'],
                    javelin: ['80m','10m','54m']
                },
            ];
届时将有超过15种运动项目,人数不详。我不知道如何在不制作大量阵列的情况下做到这一点。我一直在尝试各种方法来做到这一点,但都没有奏效

这就是我重复的内容:

<tr ng-repeat="x in ppl">
        <td>{{x.firstname}}</td>
        <td>{{x.lastname}}</td>
        <td>{{x.from}}</td>
        <td><span ng-repeat="y in x.run100m track by $index">{{ y }}</span>
        </td>
        <td><button>edit</button></td>
    </tr>

在表达式中使用属性访问器:

<tr ng-repeat="x in ppl">
    <td>{{x.firstname}}</td>
    <td>{{x.lastname}}</td>
    <td>{{x.from}}</td>
    <td><span ng-repeat="y in x[eventType] track by $index">{{ y }}</span>
    </td>
    <td><button>edit</button></td>
</tr>

{{x.firstname}
{{x.lastname}
{{x.from}}
{{y}
编辑

在表达式中使用属性访问器:

<tr ng-repeat="x in ppl">
    <td>{{x.firstname}}</td>
    <td>{{x.lastname}}</td>
    <td>{{x.from}}</td>
    <td><span ng-repeat="y in x[eventType] track by $index">{{ y }}</span>
    </td>
    <td><button>edit</button></td>
</tr>

{{x.firstname}
{{x.lastname}
{{x.from}}
{{y}
编辑

这一切都是关于为每个级别使用一致的属性名称和值类型。一项运动的名称不应该是一个键,它应该是一个更通用的值,如
sport:'javelin'
它的全部内容是为每个级别使用一致的属性名称和值类型。一项运动的名称不应该是一个键,它应该是一个更通用的值,比如
sport:'javelin'
<tr ng-repeat="x in ppl">
    <td>{{x.firstname}}</td>
    <td>{{x.lastname}}</td>
    <td>{{x.from}}</td>
    <td><span ng-repeat="y in x[eventType] track by $index">{{ y }}</span>
    </td>
    <td><button>edit</button></td>
</tr>