We can do basic search functionality in angularJs using filter like given below example. I hope this code we can also use in real time application.
<!DOCTYPE html> <html> <head> <title></title> <meta charset="utf-8" /> <script src="../Scripts/angular.js"></script> <script> var app = angular.module("MyApp", []); app.controller("MyController", function ($scope) { $scope.EmpName = [ { Name:'Ram', City:'Bangalore'}, { Name:'Mohan', City:'Bangalore'}, {Name:'Jon', City:'Bangalore'}, {Name:'Rohan', City:'Nepal'} ]; }); </script> </head> <body ng-app="MyApp"> <div ng-controller="MyController"> <p>Enter the Name to be Search <input type="text" name="EmpNameSearch" ng-model="EmpNameSearch" /> </p> <table style="border:1px solid" border="1"> <tr ng-repeat="x in EmpName |filter:EmpNameSearch"> <td style="width:200px;">{{x.Name}}</td> <td style="width:200px;">{{x.City}}</td> </tr> </table> </div> </body> </html>
Summary:
We learnt how to use basic search functionality using AngularJs Filter functionality.