Chinaunix首页 | 论坛 | 博客
  • 博客访问: 6683719
  • 博文数量: 1159
  • 博客积分: 12444
  • 博客等级: 上将
  • 技术积分: 12570
  • 用 户 组: 普通用户
  • 注册时间: 2008-03-13 21:34
文章分类

全部博文(1159)

文章存档

2016年(126)

2015年(350)

2014年(56)

2013年(91)

2012年(182)

2011年(193)

2010年(138)

2009年(23)

分类: Web开发

2016-03-16 23:09:58

http://tech-blog.maddyzone.com/javascript/implement-addeditdeleteview-php-using-angular-js-part-2


In our previous Post we have learn  How to use CRUD(create read update delete)  in angular With PHP ? Now in this post we will learn How to do Paging with Php using AngularJS or can say paging with AngularJS using Php.

Our Blog Regarding Iteration Angular JS with PHP teaches you :

How to –

– Add Product
– Edit Product
– Delete Product
– View Product in Grid Form using Angular JS and PHP.

Now we move to next part of this topic to achive filteration and paging on grid view of products we achieve in our first part of this title.

To Filter and Paging Data using PHP and Angular JS We have to follow following Steps:

First Step :

– First , we create a html for filter box in the same html file used in part-1 of this example name “angular_example.html” using below code:

– ng-change property of angular js will call function filter defined in contoller.js file as used same in part-1 of this example using below code:

 

– This filter function get the value of text we place in search box or filter box for filteration and slice
by their start index to end index to filter info on text change very frequently.

– Now, we are moving for our next step which teach you how to implement paging using angular js.

Step-2

– To Achieve Paging, We have to first declare some variables in function which gets all records from database using php and angular js defined in controller.js

– if you forgot this don’t bother , we are sohowing below the snippet of the function which will helps you in
remembering the past step you performed in part-1 of this example.

– so, if you got it here, we will move to next if you don’t please check the link below for  part-1 of same blog .

– Now as we say, we have to initialize some variable in this function to implement paging so for you  please check below variables with comment (specify the use of these variables).

so now complete code for this function is as below :

– Including this we have to define 2 new function to check the current page and filter value during paging so, we are creating here 2 new function in the same file controller.js with below code:

– As you have implemented the paging and filteration function successfully, you are now able to check complete code of controller.js here.

 

– Now as we created and updated all needed function with respective variables now we will move to our next step how to use these function in front end or on html file(angular_example.html).

Step-3

– This Step is last step to present filter and paged data on view end.

– To show or implement paged data we use following snippet code :

– If you can see this is the same snippet with updated code of paging which we used to show all items from database in part-1 of same blog.

– Now we update here te array from pagedItems to
– filtered with parameters pagedItems (total items from database)
– filter:search use the filter function with filtered text for pagination if filter box is blank than all items will come , otherwise items which full fill the criteria of filtered text will come on view end from controller.js.
– startFrom , use to show dataitems from where it will start using current page end limit for number of items to show on view table.
– Rest part is same as in previous case.

– To Present paging link we follow the following html structure.

As you have implemented the paging and filteration successfully, you are now able to check complete code of html here.

Hey , You are now able to perform all add/edit/delete/view/search/paging action using angular js with php.

please check the below snapshot with required output .

Angular With PHP Filter Paging

 

阅读(1638) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~