zoukankan      html  css  js  c++  java
  • angular 分页2

    http://www.alliedjeep.com/2547.htm

    AngularJS Code (Users.js)

    var Users = angular.module('Users', []);
    Users.controller('UserList', function($scope, $http) {
    $scope.start = 0;
    $scope.showLimit = 10;
    $scope.count = 0;
    /* Default Users List */
    $http.get('welcome/get_users' + '/' + $scope.start + '/' + $scope.showLimit).success(function(data){
    $scope.users = data;
    });
    /* Count Users */
    $http.get('welcome/count_users').success(function(data){
    $scope.count = data;
    });
    /* Pagination */
    $scope.page = function (start) {
    $scope.start = start < 0 ? 0 : start;
    if (start >= $scope.count) $scope.start = $scope.count - $scope.showLimit;
    $http.get('welcome/get_users' + '/' + $scope.start + '/' + $scope.showLimit).success(function(data){
    $scope.users = data;
    });
    }
    });
    HTML Code

    <head>
    <script src="angular.js"></script>
    <script src="Users.js"></script>
    </head>
    <body ng-controller="UserList">
    <div id="container">
    <div id="user_list">
    Search: <input class="query" type="text" ng-model="query" placeholder="Query">
    <hr />
    <table>
    <thead>
    <th>ID</th>
    <th>User Name</th>
    <th>Phone Number</th>
    <th>Email</th>
    </thead>
    <tbody>
    <tr ng-repeat="user in users | filter:query">
    <td>{{user.id}}</td>
    <td>{{user.user_name}}</td>
    <td>{{user.phone_number}}</td>
    <td>{{user.email}}</td>
    </tr>
    </tbody>
    </table>
    <hr />
    <button ng-click="page(0)">First</button>
    <button ng-click="page(start - showLimit)">Prev</button>
    <button ng-click="page(start + showLimit)">Next</button>
    <button ng-click="page(count - showLimit)">Last</button>
    <input type="text" ng-model="gotoPage" />
    <button ng-click="page(gotoPage * showLimit)">GO</button>
    </div>
    </div>
    </body>
    CSS Code (稍微美化了一下)

    body {

    margin: 40px;
    font: 13px/20px normal Helvetica, Arial, sans-serif;
    color: #4F5155;
    }
    #user_list {
    margin: 15px;
    }
    #container {
    margin: 10px;
    border: 1px solid #D0D0D0;
    box-shadow: 0 0 8px #D0D0D0;
    }
    input {
    40px;
    height: 19px;
    padding: 3px;
    color: #555;
    border-radius: 3px;
    border: 1px solid #ccc;
    }
    input.query {
    100px;
    }
    button {
    padding: 5px;

    border: 1px solid #ccc;
    border-radius: 3px;
    }
    table {
    border-spacing: 0;
    border-collapse: collapse;
    }
    td,th {
    border: 1px solid #ccc;
    text-align: center;
    padding: 5px;
    }

  • 相关阅读:
    Windows JScript 在 游览器 中运行 调试 Shell 文件系统
    autohotkey 符号链接 软连接 symbolink
    软链接 硬链接 测试
    SolidWorks 修改 基准面 标准坐标系
    手机 路径 WebDAV 映射 驱动器
    Win10上手机路径
    explorer 命令行
    单位公司 网络 封锁 屏蔽 深信 AC
    cobbler自动化部署原理篇
    Docker四种网络模式
  • 原文地址:https://www.cnblogs.com/lacey/p/5596009.html
Copyright © 2011-2022 走看看