Bootstrap + AngularJS怎么实现数据过滤字符查找功能
这篇文章主要介绍Bootstrap + AngularJS怎么实现数据过滤字符查找功能,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!
具体代码如下所示:
find.html
<!DOCTYPE html> <html ng-app="find"> <head> <title>字符查找</title> <meta charset="utf-8"/> <script src="../Script/angular.min.js" type="text/javascript"></script> <link rel="stylesheet" href="../bootstrap-3.0.0/css/bootstrap.css" rel="external nofollow" > <style type="text/css"> body{ font-size: 12px; } ul{ list-style-type: none; width: 408px; margin:0px; padding: 0px; } ul li { float: left; padding: 5px 0px; } ul .bold { font-weight: bold; cursor: pointer; } ul li span { width: 70px; float: left; padding: 0px 10px; } ul .focus { background-color: #cccccc; } </style> <script type="text/javascript"> var find = angular.module('find', []); find.controller('find_name', ['$scope', function ($scope) { $scope.bold = "bold"; $scope.key = ''; $scope.data = [ { name: "张小琴", sex: "女", age: 24, score: 95 }, { name: "李清思", sex: "女", age: 27, score: 87 }, { name: "杨旭旭", sex: "男", age: 28, score: 86 }, { name: "陈楚圣", sex: "男", age: 23, score: 97 } ]; }]) </script> </head> <body> <div ng-controller="find_name" align="center"> <div class="panel panel-primary" align="center" > <div class="panel-heading" align="center"> <div class="panel-title" >字符查找</div> </div> <div> <input id="txtkey" type="text" ng-model="key" placeholder="请输入姓名关键字" /> </div> <ul> <li ng-class="{{bold}}" > <span>序号</span> <span>姓名</span> <span>性别</span> <span>年龄</span> <span>分数</span> </li> <li ng-repeat=" stu in data | filter : {name:key}" > <span>{{$index+1}}</span> <span>{{stu.name}}</span> <span>{{stu.sex}}</span> <span>{{stu.age}}</span> <span>{{stu.score}}</span> </li> </ul> </div> </div> </body> </html>
截图:
Bootstrap是什么
Bootstrap是目前最受欢迎的前端框架,它是基于 HTML、CSS、JAVASCRIPT 的,它简洁灵活,使得 Web 开发更加快捷,它还有一个响应最好的Grid系统,并且能够在手机端通用,而Bootstrap是使用许多可重用的CSS和JavaScript组件,可以帮助实现需要的几乎任何类型的网站的功能,此外,所有这些组件都是响应式的。
以上是“Bootstrap + AngularJS怎么实现数据过滤字符查找功能”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注行业资讯频道!