NG-重复指定起始索引索引、NG

2023-09-14 00:21:20 作者:三分醉意七分醒

我怎么可以指定一个NG重复指令就要开始,而不是零的指数?

How can I specify an index where an ng-repeat directive is going to start instead of zero?

我有一组结果,我只需要指定起始之一,这是异于零。

I have a set of results and I just need to specify the starting one, which is different from zero.

推荐答案

您可以创建过滤器

app.filter('startFrom', function() {
    return function(input, start) {
        if(input) {
            start = +start; //parse to int
            return input.slice(start);
        }
        return [];
    }
});

然后你只需要使用它的NG-重复:

and then you just use it on the ng-repeat:

<div ng-repeat="item in items | startFrom : 2">{{item.Name}}</div>
 
精彩推荐
图片推荐