Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

古老的andularjs分页 #40

Open
gaowei1012 opened this issue Sep 17, 2020 · 5 comments
Open

古老的andularjs分页 #40

gaowei1012 opened this issue Sep 17, 2020 · 5 comments

Comments

@gaowei1012
Copy link
Owner

今天在处理一个angularjs项目时,遇到了一个古老的bug,现记录下

@gaowei1012
Copy link
Owner Author

在项目中使用分页,我使用的是 tm-pagination.js 这个插件,由于太过于古老,资料有限,古整理此。

找到了自作者项目地址

@gaowei1012
Copy link
Owner Author

使用如下所示
在你的项目中引入需要的文件,css & js 如下:

<link rel="stylesheet" href="lib/pagination/css/pagination.css" />

<script src="lib/pagination/js/tm.pagination.min.js"></script>

@gaowei1012
Copy link
Owner Author

gaowei1012 commented Sep 17, 2020

在你需要使用它的地方这样使用

<tm-pagination conf="paginationConf"></tm-pagination>

@gaowei1012
Copy link
Owner Author

在你的项目 xxx.component.js 这样使用

// 记住一定要注册插件
angular.module('you project name', ['tm.pagination'] ) {}

@gaowei1012
Copy link
Owner Author

gaowei1012 commented Sep 17, 2020

然后去使用

$scope.paginationConf = {
        currentPage: $location.search().currentPage ? $location.search().currentPage : 1,
        totalItems: 8000,
        itemsPerPage: 15,
        pagesLength: 15,
        perPageOptions: [10, 20, 30, 40, 50],
        onChange: function() {
            console.log($scope.paginationConf.currentPage);
            $location.search('currentPage', $scope.paginationConf.currentPage);
        }
    };

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant