ANGULARJS enables simple paging functionality

Source: Internet
Author: User

This post consists of: http://xinpure.com/angularjs-simple-paging-functionality/

Beginner AngularJS , try to write some small functions

The code logic is slightly rough, just to achieve a simple paging function, use to AngularJS taste fresh.

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
CSS Code (a little landscaping)
body {    background-color: #fff;    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 {    width: 40px;    height: 19px;    padding: 3px;    color: #555;    border-radius: 3px;    border: 1px solid #ccc;}input.query {    width: 100px;}button {    padding: 5px;    background-color: #fff;    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;}

The main logic code is written dead, not flexible, slowly improve it.

ANGULARJS enables simple paging functionality

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.