How to do basic search functionality in angularJs


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>
    <meta charset="utf-8" />
    <script src="../Scripts/angular.js"></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'}

<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>


We learnt how to use basic search functionality using AngularJs Filter functionality.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.