JavaScriptフレームワーク「AngularJS」を使用してWebアプリケーションを開発しています。 「youTube」のチュートリアルからそれを学びました。実際、私は1ページあたりのユーザーのリストを表示しようとします。つまり、1ページ目には10人のユーザーが含まれています。だから我々は のようなWebページ上のページネーションを持っています(私はそれを行う方法がわかりません)。 AngularJSへAngularJSでページネーションを作成する方法は?
-code:
app.controller("UsersController",function($scope,$http)
{
$scope.ListUsers=[];
$scope.pageNow=0;
$scope.message = "";
$scope.AllUsers=function()
{
$http.get("http://localhost:8080/ListUsers/"+$scope.pageNow)
.success(function(data){
$scope.ListUsers=data;
$scope.pages=new Array(data.totalpages);
}).error(function(err){
console.log("error:" +err);
});
};
$scope.AllUsers();
//Navigation between pages
$scope.gotoPage=function(p)
{
$scope.pageNow=p;
if ($scope.motCle == null){
$scope.AllUsers();
} else {
$scope.AllUsers();
}
};
};
- コードHTML:
<div ng-repeat="user in ListUsers"> Name:{{user.Name}} Email:{{user.Email}} </div> //here pagination <ul><li ng-class="{active:$index==pageNow}" class="clickable" ng-repeat="p in pages track by $index"> <a ng-click="gotoPage($index)">{{$index}}</a></li> </ul>
-Iは、すべての情報がうまく表示など、ページ付けされていることを結果として持っていますこれは:0-1-2-3-4-5
私はその後
ページネーションには多くのシナリオが含まれていますが、既に書かれているサードパーティ製のモジュールをお勧めします.Dire用にGoogleを使用できます。 –
私はそれに感謝します。 – emile01