星空网 > 软件开发 > Java

Part 11 Search filter in AngularJS


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 ="http://www.w3.org/1999/xhtml"><head>  <title></title>  <script src='/images/loading.gif' data-original="Scripts/angular.min.js"></script>  <script src='/images/loading.gif' data-original="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

关键词:JS

JS
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

leochan:https://www.goluckyvip.com/tag/22414.html
Leomax:https://www.goluckyvip.com/tag/22415.html
leshinehair:https://www.goluckyvip.com/tag/22416.html
letsbonus:https://www.goluckyvip.com/tag/22417.html
Letstango:https://www.goluckyvip.com/tag/22418.html
Letter of Credit:https://www.goluckyvip.com/tag/22419.html
长治婚庆女司仪和主持人:https://www.vstour.cn/a/366176.html
北京丰台区水上乐园哪家好玩?:https://www.vstour.cn/a/366177.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流