angularjsangularjs-directivedirpagination

dirPagination does not work (Angular JS pagination)


I am trying to use dirPagination but it does not work. See my code in action: http://plnkr.co/edit/18BxNhHRNyRoI17sBGQF?p=preview

My code:

<!DOCTYPE html>
<html ng-app="myApp">
<head>
<link data-require="bootstrap-css@3.1.1" data-semver="3.1.1" rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" />
<script data-require="angular.js@1.3.0-beta.5" data-semver="1.3.0-beta.5" src="https://code.angularjs.org/1.3.0-beta.5/angular.js"></script>
<script data-require="jquery@*" data-semver="2.0.3" src="http://code.jquery.com/jquery-2.0.3.min.js"></script>
<script data-require="bootstrap@3.1.1" data-semver="3.1.1" src="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>

<script>
var myApp = angular.module('myApp', [])
    .controller('PsCtrl', ['$scope', function ($scope) {
        $scope.data = [
            {a:1, b:1},
            {a:2, b:2},
            {a:3, b:3}
        ];
    }]);
</script>


<script src="dirPagination.js"></script>
</head>
<body>

<div ng-controller="PsCtrl">
    ItemCount: {{data.length}}
    <ul>
        <li dir-paginate="item in data | itemsPerPage: 2">{{ item }}</li>
    </ul>
    <dir-pagination-controls></dir-pagination-controls>
</div>
</body>
</html>

I only get this as output:

ItemCount: 3
  ⋅

But I would expect pagination controls at the bottom and this output as a first page:

ItemCount: 3
⋅ {"a":1,"b":1}
⋅ {"a":2,"b":2}

When I use <li ng-repeat="item in data">{{ item }}</li> it shows the correct list.

What am I doing wrong?


Solution

  • All you need to run your plnkr is to include dirPaginate into your angular module:

    var myApp = angular.module('myApp', ['angularUtils.directives.dirPagination'])
    

    And change path to pagination HTML template in dirpagination.js:155 to

    templateUrl:  'dirPagination.tpl.html',