How to apply Search Sort and Pagination in AngularJS Example using dir-pagination-controls

How to apply Search Sort and Pagination in AngularJS Example using dir-pagination-controls

How to apply Search Sort and Pagination in AngularJS Example using dir-pagination-controls

In this tutorial i will describe you how to create pagination for a list of records and how to apply filter on that list.

You must implement searching sorting and pagination if you are working for large data items. If you implementing these features in your application then you make your application more flexible and user friendly and also data will list in manageable order.

First you will have to display your data using dir-paginate directive. Then apply search, sort and pagination for your list of data.

Step1: Create index.html

First create a html file and declare your app using ng-app directive as ng-app="angularjsTable" and controller as ng-controller="listitemdata"

Include library of angularjs to access the features of angularjs as dir-paginate directive for creating pagination in angularjs.

  1. <!DOCTYPE html>
  2. <html lang="en" ng-app="angularjsTable">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Angular js</title>
  6. <link href='//fonts.googleapis.com/css?family=Roboto:400,300' rel='stylesheet' type='text/css'>
  7. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
  8. <script src="http://demo.expertphp.in/js/jquery.js"></script>
  9. <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
  10. <!-- Angular JS -->
  11. <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.2/angular.min.js"></script>
  12. </head>
  13. <body style="background: #e1e1e1;">
  14. <div class="panel panel-primary">
  15. <div class="panel-heading">Searching Sorting and Pagination in Angular js</div>
  16. <div class="panel-body">
  17. <div ng-controller="listitemdata">
  18. <div class="alert alert-success">
  19. <p>Sort By: {{sortBy}}</p>
  20. <p>Reverse: {{reverse}}</p>
  21. <p>Search Text : {{search}}</p>
  22. </div>
  23. <div class="col-md-12">
  24. <input type="text" ng-model="search" class="form-control" placeholder="Type your search keyword..">
  25. </div>
  26. <table class="table table-striped table-hover">
  27. <thead>
  28. <tr>
  29. <th ng-click="sort('id')">Id
  30. <span class="glyphicon sort-icon" ng-show="sortBy=='id'" ng-class="{'glyphicon-chevron-up':reverse,'glyphicon-chevron-down':!reverse}"></span>
  31. </th>
  32. <th ng-click="sort('product_name')">Product Name
  33. <span class="glyphicon sort-icon" ng-show="sortBy=='product_name'" ng-class="{'glyphicon-chevron-up':reverse,'glyphicon-chevron-down':!reverse}"></span>
  34. </th>
  35. <th ng-click="sort('product_details')">Product Details
  36. <span class="glyphicon sort-icon" ng-show="sortBy=='product_details'" ng-class="{'glyphicon-chevron-up':reverse,'glyphicon-chevron-down':!reverse}"></span>
  37. </th>
  38. </tr>
  39. </thead>
  40. <tbody>
  41. <tr dir-paginate="product in products|orderBy:sortBy:reverse|filter:search|itemsPerPage:5">
  42. <td>{{product.id}}</td>
  43. <td>{{product.product_name}}</td>
  44. <td>{{product.product_details}}</td>
  45. </tr>
  46. </tbody>
  47. </table>
  48. <dir-pagination-controls
  49. max-size="5"
  50. direction-links="true"
  51. boundary-links="true" >
  52. </dir-pagination-controls>
  53. </div>
  54. </div>
  55. </div>
  56. <script src="lib/dirPagination.js"></script>
  57. <script src="app/app.js"></script>
  58. </body>
  59. </html>

If you don't have dirpagination.js then click this link to get file of dirPagination.js and include this to index.html file.

You will notice that i have used dir-paginate to paginate over data.

Without using dir-pagination-controls table will have paginated data but don't have controls to paginate so use dir-pagination-controls to have controls over the list.

You can make changes in setting of direction-links either true or false to according show or hide next page and previous page links and boundary-links can be true or false to according show or hide first page and last page links.

ng-click event define the activity that means what should be done when HTML element is clicked.

We can bind data by using ng-model of input controls so this is helpfull in search.

Step2: create app.js

Now create app.js file to define your angular module and create controller and inject $scope and |$http in your controller.


  1. var app = angular.module('angularjsTable', ['angularUtils.directives.dirPagination']);
  2. app.controller('listitemdata',function($scope, $http){
  3.     $scope.products = []; //declare an empty array
  4.     $http.get("dataJson/demodata.json").success(function(response){
  5.         $scope.products = response; //ajax request to fetch data into $scope.data
  6.     });
  7.     
  8.     $scope.sort = function(keyname){
  9.         $scope.sortBy = keyname; //set the sortBy to the param passed
  10.         $scope.reverse = !$scope.reverse; //if true make it false and vice versa
  11.     }
  12. });

Include this file app.js in your index.html file.

I have injected angularUtils.directives.dirPagination dependencies in module to get additional benefits.

$http is a service to make request to server whenever you need to access the data of server api you use $http service to communicate with server.

Step3: Create a json file

Now create a demodata.json json file in dataJsondirectory.

  1. [{"id":1,"product_name":"Expert PHP","product_details":"Best PHP Tutorial provided"},
  2. {"id":2,"product_name":"Demo Expert PHP","product_details":"Demo"},
  3. {"id":3,"product_name":"Home Page","product_details":"Expert PHP Home Page"},
  4. {"id":4,"product_name":"Articles","product_details":"Best PHP Articles"},
  5. {"id":5,"product_name":"Tutorial","product_details":"Best PHP Tutorial"},
  6. {"id":6,"product_name":"Category","product_details":"Category"},
  7. {"id":7,"product_name":"Tag","product_details":"Tags"},
  8. {"id":8,"product_name":"AngularJS","product_details":"AngularJS"},
  9. {"id":9,"product_name":"Module","product_details":"Pagination, Searching with Sorting"}]

For now i make a ajax request using $http service for a file that contain dummy data.

Now you can try this code in your application for search sort and pagination in angularjs.

Phone: (+91) 8800417876
Noida, 201301
Bahis forum Bahis forumu Deneme bonusu
gaziantep escort title="gaziantep escort bayan">gaziantep escort bayan gaziantep escort
esenyurt escort
ataşehir escort maltepe escort escort bayan anadolu yakası escort kaliteli escort anadolu yakası escort çekmeköy escort ümraniye escort kurtköy escort anadolu yakası escort escort bayan bostancı escort ataşehir escort ümraniye escort
pendik escort
izmir escort izmir escort izmir escort izmir escort denizli escort antalya escort antalya escort antalya escort izmir escort izmir escort izmir escort izmir escort izmir escort
kocaeli escort izmit escort bayan gebze escort izmit sınırsız escort escort bursa tuzla escort aydınlı escort orhanlı escort bursa escort escort bayan istanbul escort istanbul sınırsız escort istanbul bayan escort izmit escort izmit escort kocaeli escort sisli escort mecidiyekoy escort bursa escort bayan bursa görükle escort maltepe escort goztepe escort yakacik-yeni-escort bursa sınırsız escort sisli escort bayan taksim escort bursa escort porno izle sikiş izle atasehir escort antalya escort ankara escort etlik escort çankaya escort kızılay escort demetevler escort dikmen escort esat escort eryaman escort ankara escort bayan
ankara escort marmaris escort bursa escort mersin escort antalya escort izmir escort samsun escort bodrum escort çeşme escort kuşadası escort adana escort eskişehir escort gaziantep escort esenyurt escort pendik escort tuzla escort fatih escort ümraniye escort mecidiyeköy escort kartal escort bahçelievler escort bahçeşehir escort ataşehir escort bakırköy escort nişantaşı escort avcılar escort büyükçekmece escort kurtkoy escort konya escort beşiktaş escort taksim escort beylikdüzü escort malatya escort sakarya escort şişli escort maltepe escort kadıköy escort ataköy escort bostancı escort şirinevler escort bağcılar escort üsküdar escort etiler escort başaksehir escort ortaköy escort kağıthane escort sultangazi escort halkalı escort çekmeköy escort şaşkınbakkal escort mamak escort sincan escort keçiören escort çankaya escort beypazarı escort akyurt escort pursaklar escort kahramankazan escort göztepe escort alsancak escort bornova escort buca escort karabaglar escort karşıyaka escort konak escort narlıdere escort izmit escort başiskele escort kandira escort körfez escort karamürsel escort dilovası escort gölcük escort gebze escort kocaeli escort kayseri escort elazığ escort denizli escort diyarbakir escort adana escort ankara escort izmir escort antalya escort gaziantep escort kayseri escort konya escort mersin escort denizli escort kocaeli escort diyarbakır escort alanya escort manavgat escort bursa escort eskişehir escort sakarya escort samsun escort malatya escort trabzon escort adıyaman escort afyon escort ağrı escort aksaray escort amasya escort ardahan escort artvin escort aydın escort balikesir escort bartın escort batman escort bayburt escort bilecik escort bingöl escort bitlis escort bolu escort burdur escort çanakkale escort çankırı escort çorum escort düzce escort edirne escort elazığ escort erzincan escort erzurum escort giresun escort gümüşhane escort hatay escort ığdır escort ısparta escort maraş escort karabük escort karaman escort kars escort kastamonu escort kilis escort kırıkkale escort kırklareli escort kırşehir escort kütahya escort manisa escort mardin escort muğla escort muş escort nevşehir escort niğde escort ordu escort osmaniye escort rize escort urfa escort siirt escort sinop escort şırnak escort sivas escort ordu escort tokat escort tunceli escort usak escort van escort yalova escort yozgat escort zonguldak escort kıbrıs escort
adana escort adapazarı escort afyon escort aksaray escort alanya escort aliağa escort amasya escort antalya escort ataşehir escort aydın escort balıkesir escort bartın escort batman escort bayraklı escort bilecik escort bodrum escort bolu escort bornova escort buca escort burdur escort bursa escort çanakkale escort çankırı escort çorum escort darıca escort didim escort edirne escort edremit escort elazığ escort konya escort eryaman escort kıbrıs escort eskişehir escort fethiye escort giresun escort gümüşhane escort güngören escort hatay escort iskenderun escort ısparta escort gaziemir escort karabük escort karaman escort karşıyaka escort kaş escort kastamonu escort kayseri escort kırıkkale escort kırklareli escort kırşehir escort kocaeli escort kuşadası escort kütahya escort lara escort malatya escort manisa escort maraş escort mersin escort muğla escort nevşehir escort niğde escort ödemiş escort ordu escort osmaniye escort pendik escort sakarya escort atakum escort samsun escort sincan escort sinop escort sivas escort tekirdağ escort tokat escort trabzon escort tuzla escort urfa escort uşak escort düzce escort yalova escort yozgat escort zonguldak escort dörtyol escort antakya escort yüreğir escort bandırma escort gürsu escort marmaris escort ereğli escort çorlu escort afşin escort gemlik escort kemer escort karatay escort selçuklu escort beyşehir escort bosna escort ceyhan escort nazilli escort talas escort yıldırım escort

viagra sipariş

lifta 20 mg

cialis fiyat

viagra 100 mg fiyat

cialis jel

viagra satın al

cialis 5 mg fiyat

viagra satın al

viagra fiyatı

degra

vigrande

degra 100 mg

orcafil

cialis nedir

cialis 20 mg eczane fiyatı

cialis fiyat

cialis 20 mg

cialis 100 mg

viagra fiyat

lifta

lifta 5 mg

hardcis

cialis eczane

cialis 5 mg fiyatı

cialis 100 mg fiyat

cialis 5 mg

viagra fiyatları

viagra satış

online eczane viagra

viagra eczane

cialis 20 mg

cialis 100 mg

cialis hap

cialis 20

cialis eczane

cialis satış

cialis fiyatları

cialis fiyatı

viagra fiyat

viagra fiyatları

viagra eczane

viagra satın al

pfizer viagra satış

online eczane viagra

pfizer viagra satın al

viagra sipariş

viagra sipariş hattı

viagra fiyat 2022

online viagra sipariş

viagra fiyat 2022 eczane

viagra fiyat eczane

cialis 5 mg

kamagra satın al

kamagra

kamagra jel

kamagra jel sipariş

kamagra sipariş

kamagra fiyat

kamagra jel fiyatı

kamagra fiyatı

kamagra 100mg

kamagra 100mg fiyat

süper kamagra

kamagra nedir

Ereksiyon Hapları

orcafil 5 mg

flynta 5 mg

lifta 5 mg

flynta 20 mg

lifta 20 mg

degra fiyat

degra 100 mg

sildegra 100 mg

sildegra

sinegra

vigrande

vigrande 100 mg

combo 100 mg

vigaroo

jeligra

cialis satış

cialis 100 mg fiyat

cialis 20 mg eczane fiyatı

cialis 5 mg

cialis hap

cialis 5 mg fiyatı

cialis nedir

cialis 100 mg

cialis 20 mg

cialis fiyat

cialis

viagra fiyatı 2021

viagra fiyat

viagra yorum

viagra nedir

viagra satın al

viagra sipariş

eczane viagra

viagra 100 mg

orijinal viagra

viagra 100 mg fiyat

novagra

geciktirici krem

geciktirici sprey

viga krem

viga sprey

nely8

stag sprey

delay sprey

geciktirici mendil

geciktirici

viagra fiyat viagra fiyatları cialis 20 mg cialis 100 mg kamagra kamagra jel vega 100 vega 100 mg viagra cialis
iskenderun escort, iskenderun escort, iskenderun escort, hatay escort, iskenderun escort, iskenderun escort, iskenderun escort, iskenderun escort, iskenderun escort, iskenderun escort, iskenderun escort, iskenderun escort, antakya escort, antakya escort, bursa escort, bursa escort, hatay escort,
diyarbakır escort, diyarbakır escort, elazığ escort, elazığ escort, arsuz escort, arsuz escort, denizli escort, denizli escort, denizli escort, denizli escort, denizli escort, denizli escort, denizli escort, denizli escort, denizli escort, denizli escort, denizli escort, denizli escort, denizli escort, denizli escort, denizli escort, denizli escort, denizli escort, denizli escort, denizli escort,
adana escort, adana escort, adana escort, adana escort, adana escort, malatya escort, malatya escort, eskişehir escort, eskişehir escort, manisa escort, izmit escort, izmit escort, izmit escort, izmit escort, izmit escort, izmit escort, izmit escort, izmit escort, izmit escort, ısparta escort, ankara escort, ankara escort, gaziantep escort, gaziantep escort, gaziantep escort, seks hikayeleri, erotik hikayeleri, erotik seks hikayeleri, sakarya escort, sakarya escort, sakarya escort,
izmir escort
ataşehir escort