简体   繁体   English

Angularjs“跳转到页面”分页

[英]Angularjs "jump to page" pagination

I have a pagination function, and I would like to create a textbox and button where user can enter the page number they want to go.我有一个分页功能,我想创建一个文本框和按钮,用户可以在其中输入他们想要的页码。 Is there a way to do this?有没有办法做到这一点? Would appreciate it if I could get a reference link or something.如果我能得到一个参考链接或其他东西,我将不胜感激。 Thanks!谢谢!

My HTML :我的 HTML :

<div class="pagingDiv">
<button class="btnPaging" ng-disabled="currentPage == 0" ng-click="currentPage=currentPage-1">
    Previous
</button>
{{currentPage+1}}/{{numberOfPages()}}
<button class="btnPaging" ng-disabled="currentPage >= data.length/pageSize - 1" ng-click="currentPage=currentPage+1">
    Next
</button>
</div>

JS: JS:

                 $scope.currentPage = 0;
                 $scope.pageSize = 4;
                 $scope.data = [];
                 $scope.numberOfPages=function(){
                     return Math.ceil($scope.data.length/$scope.pageSize);
                 }
                 for (var i=0; i < $scope.displayPage.length; i++) {
                     $scope.data.push("Item "+ i);
                 }

How it look like currently目前的样子

在此处输入图片说明

Expected Result:预期结果:

在此处输入图片说明

Use a text box and bind the model currentPage to it.使用文本框并将模型currentPage绑定到它。

    <button class="btnPaging" ng-disabled="currentPage >= data.length/pageSize - 1" ng-click="currentPage=currentPage+1">
Next
    </button>
    <input ng-model="currentPage" type="text">
    <button type="button" ng-click="ChangePage()"></button>

You can use the ChangePage function on you angular file to change the page.您可以使用角度文件上的 ChangePage 功能来更改页面。 and use the text box to bind the current page variable.并使用文本框绑定当前页面变量。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM