filmov
tv
Search filter in AngularJS
Показать описание
angularjs search filter example
angularjs search box example
In this video we will discuss, how to implement search in Angular using search filter.
Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help.
As we type in the search textbox, all the columns in the table must be searched and only the matching rows should be displayed.
var app = angular
.module("myModule", [])
.controller("myController", function ($scope) {
var employees = [
{ name: "Ben", gender: "Male", salary: 55000, city: "London" },
{ name: "Sara", gender: "Female", salary: 68000, city: "Chennai" },
{ name: "Mark", gender: "Male", salary: 57000, city: "London" },
{ name: "Pam", gender: "Female", salary: 53000, city: "Chennai" },
{ name: "Todd", gender: "Male", salary: 60000, city: "London" },
];
});
[!DOCTYPE html]
[head]
[title][/title]
[/head]
[body ng-app="myModule"]
[div ng-controller="myController"]
Search : [input type="text" ng-model="searchText" placeholder="Search employees" /]
[br /][br /]
[table]
[thead]
[tr]
[th]Name[/th]
[th]Gender[/th]
[th]Salary[/th]
[th]City[/th]
[/tr]
[/thead]
[tbody]
[tr ng-repeat="employee in employees | filter:searchText"]
[/tr]
[/tbody]
[/table]
[/div]
[/body]
[/html]
body {
font-family: Arial;
}
table {
border-collapse: collapse;
}
td {
border: 1px solid black;
padding: 5px;
}
th {
border: 1px solid black;
padding: 5px;
text-align: left;
}
At the moment, the search is being done across all columns. If you want to search only one specific column, then change ng-model directive value on the search textbox as shown below. With this change only city column is searched.
Link for all dot net and sql server video tutorial playlists
Link for slides, code samples and text version of the video
angularjs search box example
In this video we will discuss, how to implement search in Angular using search filter.
Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help.
As we type in the search textbox, all the columns in the table must be searched and only the matching rows should be displayed.
var app = angular
.module("myModule", [])
.controller("myController", function ($scope) {
var employees = [
{ name: "Ben", gender: "Male", salary: 55000, city: "London" },
{ name: "Sara", gender: "Female", salary: 68000, city: "Chennai" },
{ name: "Mark", gender: "Male", salary: 57000, city: "London" },
{ name: "Pam", gender: "Female", salary: 53000, city: "Chennai" },
{ name: "Todd", gender: "Male", salary: 60000, city: "London" },
];
});
[!DOCTYPE html]
[head]
[title][/title]
[/head]
[body ng-app="myModule"]
[div ng-controller="myController"]
Search : [input type="text" ng-model="searchText" placeholder="Search employees" /]
[br /][br /]
[table]
[thead]
[tr]
[th]Name[/th]
[th]Gender[/th]
[th]Salary[/th]
[th]City[/th]
[/tr]
[/thead]
[tbody]
[tr ng-repeat="employee in employees | filter:searchText"]
[/tr]
[/tbody]
[/table]
[/div]
[/body]
[/html]
body {
font-family: Arial;
}
table {
border-collapse: collapse;
}
td {
border: 1px solid black;
padding: 5px;
}
th {
border: 1px solid black;
padding: 5px;
text-align: left;
}
At the moment, the search is being done across all columns. If you want to search only one specific column, then change ng-model directive value on the search textbox as shown below. With this change only city column is searched.
Link for all dot net and sql server video tutorial playlists
Link for slides, code samples and text version of the video
Комментарии