zoukankan      html  css  js  c++  java
  • 14.名字查找

    初始页面

    -----------------------------------------------------------------------------------------------------

    查找效果

    -------------------------------------------------------------------------------------------------

     1 <!DOCTYPE html>
     2 <html ng-app="a3_5" ng-controller="c3_5">
     3 <head lang="en">
     4     <meta charset="UTF-8">
     5     <title>T37-字符查找</title>
     6     <script src="js/angular.js" type="text/javascript"></script>
     7     <style type="text/css">
     8         body {
     9             font-size: 20px;
    10         }
    11 
    12         ul {
    13             list-style-type: none;
    14              700px;
    15             height: 200px;
    16             margin: 50px auto;
    17         }
    18 
    19         ul li {
    20             float: left;
    21             padding: 5px 0;
    22         }
    23 
    24         ul .bold {
    25             font-weight: bold;
    26             cursor: pointer;
    27         }
    28 
    29         ul li span {
    30              60px;
    31             float: left;
    32             padding: 0;
    33         }
    34 
    35         ul .focus {
    36             background-color: #ccc;
    37         }
    38 
    39         .pi {
    40             margin:50px 450px;
    41         }
    42     </style>
    43 
    44 
    45 </head>
    46 <body>
    47 <div class="pi"><input type="text" id="txtkey" ng-model="key" placeholder="根据名字查找"/></div>
    48 
    49 <ul>
    50     <li ng-class="'{{bold}}'">
    51         <span>序号</span>&nbsp;
    52         <span>姓名</span>&nbsp;&nbsp;&nbsp;&nbsp;
    53         <span>性别</span>&nbsp;&nbsp;&nbsp;&nbsp;
    54         <span>年龄</span>&nbsp;
    55 
    56     </li>
    57     <li ng-repeat="stu in data | filter : {name:key}">
    58         <span>{{$index+1}}</span>&nbsp;
    59         <span>{{stu.name}}</span>&nbsp;&nbsp;&nbsp;&nbsp;
    60         <span>{{stu.sex}}</span>&nbsp;&nbsp;&nbsp;&nbsp;
    61         <span>{{stu.age}}</span>&nbsp;
    62 
    63     </li>
    64 </ul>
    65 
    66 </body>
    67 
    68 <script type="text/javascript">
    69     var app = angular.module("a3_5", []);
    70     app.controller("c3_5", ['$scope', function ($scope) {
    71         $scope.bold = "bold";
    72         $scope.key = '';
    73         $scope.data = [
    74             {name: "张明", sex: "女", age: 24},
    75             {name: "李清", sex: "女", age: 25},
    76             {name: "秦风", sex: "男", age: 22},
    77             {name: "苏眠", sex: "女", age: 28}
    78         ];
    79     }])
    80 
    81 
    82 </script>
    83 
    84 </html>
    View Code

    关键代码:

     ng-model="key"

    <li ng-repeat="stu in data | filter : {name:key}">
  • 相关阅读:
    STM32低功耗模式与烟雾报警器触发信号电路设计
    cocos2d-x的环境的搭建
    window8.1中用户的管理员权限的提升方法
    cmd中目录的变更
    js的传值,table中tr的遍历,js中动态创建数组
    究竟什么是游戏引擎?
    大型网站架构学习心德
    关于listView 中的聚焦问题
    android6.0 适配的问题——activity销毁的问题
    文件发送成功率低的问题(2)
  • 原文地址:https://www.cnblogs.com/mx2036/p/6704790.html
Copyright © 2011-2022 走看看