How to do paging in AngularJS?

后端 未结 21 1907
轮回少年
轮回少年 2020-11-22 07:17

I have a dataset of about 1000 items in-memory and am attempting to create a pager for this dataset, but I\'m not sure on how to do this.

I\'m using a custom filter

21条回答
  •  终归单人心
    2020-11-22 07:58

    I wish I could comment, but I'll just have to leave this here:

    Scotty.NET's answer and user2176745's redo for later versions are both great, but they both miss something that my version of AngularJS (v1.3.15) breaks on:

    i is not defined in $scope.makeTodos.

    As such, replacing with this function fixes it for more recent angular versions.

    $scope.makeTodos = function() {
        var i;
        $scope.todos = [];
        for (i=1;i<=1000;i++) {
            $scope.todos.push({ text:'todo '+i, done:false});
        }
    };
    

提交回复
热议问题