您好,欢迎来到意榕旅游网。
搜索
您的当前位置:首页在Angular中如何实现orderBy排序与模糊查询

在Angular中如何实现orderBy排序与模糊查询

来源:意榕旅游网
这篇文章主要介绍了Angular实现的内置过滤器orderBy排序与模糊查询功能,涉及AngularJS过滤器、排序及字符串遍历、查询等相关操作技巧,需要的朋友可以参考下

本文实例讲述了Angular实现的内置过滤器orderBy排序与模糊查询功能。分享给大家供大家参考,具体如下:

先来看看运行效果:

具体代码如下:

<!DOCTYPE html>
<html lang="en">
<head>
 <meta charset="UTF-8">
 <title>www.gxlcms.com 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>
<p>{{price|currency:"¥"}}</p>
</body>
</html>

上面是我整理给大家的,希望今后会对大家有帮助。

相关文章:

有关Axios的配置步骤(详细教程)

在JS中有关兼容浏览器问题

使用JS如何才能获取SessionStorage的值

利用node.js等技术如何实现登录注册功能?

在vue中如何使用filter过滤器

Copyright © 2019- yrrf.cn 版权所有

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务