Simple search filter with angularjs and php - Mostlikers

19 August, 2015

Simple search filter with angularjs and php

Everyone must know about AngularJS. it's fits the definition of a framework the best. AngularJS will get quick server response in client side. based on server response i have create search filer code. Here i have explain about how to create simple search filter using with AngularJS and php. 

                                      Live Demo                     Download

Recently i have posted dynamic data binding in AngularJS tutorials. here i have explained basic of angular.

ng-app            => The ng-app directive defines an AngularJS application.
ng-modules    => The ng-model directive binds the value of HTML controls.
ng-controller  => The ng-controller directive is used to (implicitly) create a scope for our template.
ng-repeat       =>  make loop for object data. simlar

If you want to use AngularJS script in your website you must have to add angular.min.js external libraries.


<html ng-app=MostlikerApp>
    <script src=""></script>
  <body ng-controller="demoCtrl">      
            <td align="right">Search :</td>
            <td><input ng-model="query[queryBy]" /></td>
            <tr ng-repeat="article in articles | filter:query">
                <td>{{$index + 1}}</td>
                <td><a target="_blank" href="{{}}">{{}}</a></td>


Convert your php data into json data. create sample table name called 'demos ' and  column. after get your php result convert json format use Json_encode convert array format data to json format.
    $db=new mysqli('localhost','root','','mostlikers'); 
    $sql=$db->query("SELECT * FROM demos ORDER BY lastupdate DESC"); 
    foreach($sql as $rec)//foreach loop  
    $my_demos = json_encode($json_data,JSON_PRETTY_PRINT);


Create app module and controller pass php json data.
<script type="text/javascript">
 var MostlikerApp = angular.module("MostlikerApp",[]);
    $scope.query = {}
    $scope.queryBy = '$'
    $scope.articles = <?php echo $my_demos; ?>;

Thank you for visiting. if have any queries write your comments below.

"To succeed in your mission, you must have single-minded devotion to your goal. "
                                         - A. P. J. Abdul Kalam

Related Topics


  1. kaise ho, karthick bhai
    humko tumhra i tutorial bohot pasand aaya, bus tumko thanku kehnekeliye i comment kiye he ...
    thanku or bahut shukria...

    1. Hume aacha laga ye jaan kar ki aapko humara tutorial pasand aya, Agar kabhi bhi koi doubt ho to humare mostlikers ke page pe post karen, hum aapke queries ka solution bhejenge