Search filter in AngularJS:-
In this topic we will exlain about search filter in AngularJS.
As we type in the search textbox as in below image, all the columns in the table must be searched and only the matching rows should be displayed.
We want following type output:
Example:-
Demo.js
var app = angular
.module("myModule", [])
.controller("myController", function ($scope) {
var employees = [
{ name: "Anu", gender: "Female", salary: 5000, city: "Noida" },
{ name: "Santosh Kumar Singh", gender: "Male", salary: 6000, city: "Patna" },
{ name: "Abhinav Kumar", gender: "Male", salary: 5000, city: "New Delhi" },
{ name: "Manorma", gender: "Female", salary: 4000, city: "New Delhi" },
{ name: "Gagan", gender: "Female", salary: 3000, city: "Haryana" },
{ name: "Priyanka", gender: "Female", salary: 7000, city: "Delhi" },
{ name: "Pramod Kumar Sah", gender: "male", salary: 8000, city: "Madhuabni" },
];
$scope.employees = employees;
});
Demo.html
Search filter in AngularJS Demo by santosh-asp.com
Now, we run the application and get output as expected:
As we type in the search textbox as in below image, all the columns in the table must be searched and only the matching rows should be displayed.
We want following type output:
Example:-
Demo.js
Demo.html
Search filter in AngularJS Demo by santosh-asp.com
Search :
Name
Gender
Salary
City
{{ employee.name }}
{{ employee.gender }}
{{ employee.salary }}
{{ employee.city }}
Name | Gender | Salary | City |
---|---|---|---|
{{ employee.name }} | {{ employee.gender }} | {{ employee.salary }} | {{ employee.city }} |
Now, we run the application and get output as expected: