I am trying to implement ui.bootstrap.pagination in my angularJS project, but I cannot seem to read the current page number, even though I have set ng-model. I am using angular-ui-bootstrap version 0.13.3.
The relevant part of my html:
<pagination
data-ng-model="currentPage"
data-ng-change = "paginate()"
data-total-items="repositories.total_count"
data-items-per-page="numPerPage"
data-max-size="maxSize"
data-boundary-links="true" >
</pagination>
And my code:
angular.module('myApp.repositories')
.controller('RepositoryController', ['$scope', function($scope) {
$scope.repositories = {};
$scope.currentPage = 1;
$scope.numPerPage = 30; // Number of items per page, set by Github API
$scope.maxSize = 10; // Number of pages to show in pagination
$scope.paginate = function() {
$http.get('https://api.github.com/search/repositories/', {
params: {
q: 'twitter',
page: $scope.currentPage
}
})
.then(function(response){
if(response.data){
$scope.repositories = response.data;
}
});
};
}]);
The pagination shows as expected and I can use it without it throwing errors, but in my paginate() function $scope.currentPage always reads 1.
I could be missing or overlooking something very basic, but I cannot seem to figure out why it isn't working.