I am currently working on implementing a directive pagination feature and I need to pass the current page number from the directive to a controller in order to run a specific function with this argument. However, I keep getting an 'undefined' error.
<account-pagination pagination-config="paginationConfig" on-change="pageChanged()">
</account-pagination>
Controller:
$scope.pageChanged = function(page) {
console.log(page); // undefined
}
Directive:
scope: {
paginationConfig: '=',
onChange: '&',
}
$scope.moveToPage = function(numPage) {
$scope.currentPage = numPage;
getPaginData(numPage);
}
function getPaginData(numPage) {
$scope.onChange({page: numPage});
}
Template Directive:
<li ng-repeat="num in numPages"><a ng-click="moveToPage(num)" ng-class="{pageActive: isActive(num)}">{{num}}</a></li>