1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| angular.module('MyApp', ['services']).controller('MyCtrlG', function($scope, $http, Logger) {
$scope.afficherPage=function(x){
console.log("chui làà");
}
}
$scope.setPager=function(x){
var ul = document.getElementById('pager');
$scope.RemoveAllChild('pager');
var fp = document.createElement('li');
var lp = document.createElement('li');
var prev = document.createElement('li');
var next = document.createElement('li');
fp.setAttribute('class','first-page');
fp.innerHTML = '<a onclick="$scope.afficherPage(\'fp\')" href="#">«</a>';
ul.appendChild(fp);
prev.innerHTML = '<a onclick="$scope.afficherPage(\'prev\')" href="#" >‹</a>';
ul.appendChild(prev);
n=x; if(n>10) n=10;
for (var i = 1; i <= n; i++) {
var li = document.createElement('li');
if(i==1) li.setAttribute('class','active');
li.innerHTML = '<a onclick="$scope.afficherPage('+i+')" href="#" >'+i+'</a>';
ul.appendChild(li);
}
if(x>10){
var li = document.createElement('li');
li.innerHTML = '<p>.....</p>';
ul.appendChild(li);
}
next.innerHTML = '<a onclick="$scope.afficherPage(\'next\')" href="#">›</a>';
ul.appendChild(next);
lp.setAttribute('class','last-page');
lp.innerHTML = '<a onclick="$scope.afficherPage(\'lp\')" href="#">»</a>';
ul.appendChild(lp);
return x;
}
}); |
Partager