Angular实现的内置过滤器orderBy排序与模糊查询功能示例
更新时间:2017年12月29日 12:11:16 作者:当爱0201
这篇文章主要介绍了Angular实现的内置过滤器orderBy排序与模糊查询功能,涉及AngularJS过滤器、排序及字符串遍历、查询等相关操作技巧,需要的朋友可以参考下
本文实例讲述了Angular实现的内置过滤器orderBy排序与模糊查询功能。分享给大家供大家参考,具体如下:
先来看看运行效果:

具体代码如下:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>www.jb51.net Angular模糊查询、排序</title>
<style>
*{
margin: 0;
padding: 0;
}
table{
margin: 100px auto;
border-collapse: collapse;
}
th,td{
padding: 10px;
border: 1px solid #000;
}
</style>
<script src="angular.min.js"></script>
<script>
var myapp=angular.module("myapp",[]);
myapp.controller("myCtrl",function ($scope) {
$scope.books=[{
name:"JavaScript",public:false,update:"1504707661308",has:true
},{
name:"Angular权威教程",public:false,update:"1204707661308",has:false
},{
name:"Vue实战",public:false,update:"1804707661308",has:false
},{
name:"JavaScript",public:true,update:"1504707561308",has:true
}];
$scope.price="99.9";
/*$scope.filt=""*/
})
</script>
</head>
<body ng-app="myapp" ng-controller="myCtrl">
<input type="text" ng-model="filt">
<table>
<thead><tr>
<th>名字</th>
<th>出版情况</th>
<th>更新时间</th>
<th>是否有库存</th>
</tr></thead>
<tbody>
<!--|limitTo:2显示两条数据-->
<tr ng-repeat="item in books | filter:filt |orderBy:'-name':false">
<td>{{item.name|lowercase}}</td>
<td>{{item.public}}</td>
<td>{{item.update |date:'yyyy年MM月dd日 hh:mm:ss EEE'}}</td>
<td>{{item.has}}</td>
</tr>
</tbody>
</table>
<div>{{price|currency:"¥"}}</div>
</body>
</html>
更多关于AngularJS相关内容感兴趣的读者可查看本站专题:《AngularJS指令操作技巧总结》、《AngularJS入门与进阶教程》及《AngularJS MVC架构总结》
希望本文所述对大家AngularJS程序设计有所帮助。
相关文章
angularjs利用directive实现移动端自定义软键盘的示例
下面小编就为大家带来一篇angularJS利用directive实现移动端自定义软键盘的示例。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧2017-09-09
Angular.js跨controller实现参数传递的两种方法
这篇文章主要给大家介绍了关于Angular.js跨controller实现参数传递的两种方法,文中给出了详细的介绍和示例代码,相信对大家具有一定的参考价值,需要的朋友们下面来一起看看吧。2017-02-02


最新评论