Part 11 Search filter in AngularJS
As we type in the search textbox, all the columns in the table must be searched and only the matching rows should be displayed.
Script.js :
- 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" },
- ];
- $scope.employees = employees;
- });
HtmlPage1.html :
- <!DOCTYPE html>
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <title></title>
- <script src="Scripts/angular.min.js"></script>
- <script src="Scripts/Script.js"></script>
- <link href="Styles.css" rel="stylesheet" />
- </head>
- <body ng-app="myModule">
- <div ng-controller="myController">
- Search : <input type="text" placeholder="Search employees"
- ng-model="searchText" />
- <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">
- <td> {{ employee.name }} </td>
- <td> {{ employee.gender }} </td>
- <td> {{ employee.salary }} </td>
- <td> {{ employee.city }} </td>
- </tr>
- </tbody>
- </table>
- </div>
- </body>
- </html>
Styles.css :
- 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;
- }
Part 11 Search filter in AngularJS的更多相关文章
- Part 13 Create a custom filter in AngularJS
Custom filter in AngularJS 1. Is a function that returns a function 2. Use the filter function to cr ...
- ArcEngine中IFeatureClass.Search(filter, Recycling)方法中Recycling参数的理解
转自 ArcEngine中IFeatureClass.Search(filter, Recycling)方法中Recycling参数的理解 ArcGIS Engine中总调用IFeatureCla ...
- AngularJS filter:search 是如何匹配的 ng-repeat filter:search ,filter:{$:search},只取repeat的item的value 不含label
1. filter可以接收参数,参数用 : 进行分割,如下: {{ expression | filter:argument1:argument2:... }} 2. filter参数是 对象 ...
- AngularJS的运用
前 言 JRedu AngularJS[1] 诞生于2009年,由Misko Hevery 等人创建,后为Google所收购.是一款优秀的前端JS框架,已经被用于Google的多款产品当中.A ...
- AngularJS快速入门指南20:快速参考
thead>tr>th, table.reference>tbody>tr>th, table.reference>tfoot>tr>th, table ...
- angularjs 学习小结
1.过滤器的使用 <!DOCTYPE html> <html> <head> <meta charset="{CHARSET}"> ...
- AngularJS过滤排序思路
本篇主要整理使用AngularJS进行过滤排序的思路. 在controller中,$scope的persons字段存储数组. $scope.persons = [ { "name" ...
- AngularJS:自定义过滤器
表达式: {{ expression | filter1 | filter2 | ... }} {{ expression | filterName : paramet ...
- Netsuite SuiteScript > Search Advance feature,搜索中使用 'OR' operation
Sample in online help //Define search filter expression var filterExpression = [ [ 'trandate', 'onOr ...
随机推荐
- IC开短路测试(open_short_test),编程器测试接触不良、开短路
http://kitebee.meibu.com/forum.php?mod=viewthread&tid=69654&extra=page%3D5 IC开短路测试(open_shor ...
- SAE J1708 DS36277 MAX3444, DS75176B
http://en.wikipedia.org/wiki/J1708 J1708 SAE J1708 is a standard used for serial communications betw ...
- Codeforces Round #306 (Div. 2) E. Brackets in Implications 构造
E. Brackets in Implications Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/conte ...
- Codeforces Round #136 (Div. 1)C. Little Elephant and Shifts multiset
C. Little Elephant and Shifts Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/pro ...
- 基于私钥加密公钥解密的RSA算法C#实现
RSA算法是第一个能同时用于加密和数字签名的算法,也易于理解和操作. RSA是被研究得最广泛的公钥算法,从提出到现在已近二十年,经历了各种攻击的考验,逐渐为人们接受,普遍认为是目前最优秀的公钥方案之一 ...
- Java中类的初始化顺序
一.一个类的初始化顺序(没继承情况) 规则: 1.静态变量>普通变量>构造方法 2.变量定义的顺序决定初始化的顺序 3.静态变量和静态块是一样的,普通变量和非静态块是一样的,即能够把 ...
- [Angular2 Form] Style Validation in Angular 2 Forms
Inputs using Angular 2’s ngModel automatically apply style classes of .ng-validand .ng-invalid each ...
- Memcached概述
Memcached Memcached是一套分布式的内存对象缓存系统,使用C语言编写,作为数据库的前端cache,缓存数据库查询结果能够减轻数据库负载. 类似一张巨大的hash表,缓存的对象以key- ...
- 激活office 2010
在激活office 2010版本时有的同学可能会用到“mini-KMS_Activator”这个工具,其实这个工具激活成功率并不算高,我就没激活成功.然后就是了另一款自动激活工具“Office 201 ...
- innobackupex 备份实验
[root@localhost ~]# xtrabackup -v xtrabackup version based Linux (x86_64) (revision id: 45cda89) [ro ...