NG-重复指定起始索引 [英] ng-repeat specify a starting index

查看:155
本文介绍了NG-重复指定起始索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎么可以指定一个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>

这篇关于NG-重复指定起始索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆