File Name: Script.js in Scripts folder.
/// <reference path="angular.min.js" />
var myApp = angular.module("myModule", []);
var myController = function ($scope)
{
var Employee = [
{
LastName: "Parihar",Gender: "Male",Address: "Pune",
},
{
FirstName: "Shiva",LastName: "Parihar",Gender: "Male",Address: "Pune",
},
{
FirstName: "Mili",LastName: "Zen",Gender: "Female",Address: "US",
},
{
FirstName: "Divya",LastName: "Singh",Gender: "Female",Address: "Nagpur",
},
{
FirstName: "Digvijay",LastName: "Chauhan",Gender: "Male",Address: "Pune",
}];
$scope.Emp = Employee;
};
myApp.controller("myCont", myController);
<!DOCTYPE html>
<html ng-app="myModule">
<head>
<script src="Scripts/angular.min.js" type="text/javascript"></script>
<script src="Scripts/Script.js"></script>
<style>
table, th, td
{
border: 1px solid grey;
border-collapse: collapse;
padding: 5px;
}
table tr:nth-child(odd)
{
background-color: #ffe6e6;
}
table tr:nth-child(even)
{
background-color: #ccffcc;
}
</style>
</head>
<body style="font-family:Arial; font-size:medium; color:darkblue">
<div ng-controller="myCont">
<h3>Search functionality in AngularJS.</h3>
<br/>
<h3> Search Employee : <input type="text" ng-model= "searchEmp"/></h3>
<br/><br/>
<table>
<tr>
<th>FirstName</th>
<th>LastName</th>
<th>Gender</th>
<th>Address</th>
</tr>
<tr ng-repeat="e in Emp | filter:searchEmp">
<td>{{e.FirstName}}</td>
<td>{{e.LastName}}</td>
<td>{{e.Gender}}</td>
<td>{{e.Address}}</td>
</tr>
</table>
</div>
</body>
</html>