首页 > 其他 > 详细

angular过滤器

时间:2017-07-04 14:02:02      阅读:205      评论:0      收藏:0      [点我收藏+]

<!doctype html>
<html lang="en" ng-app="myApp">
<head>
 <meta charset="UTF-8" />
 <title>Document</title>
</head>
<body>
 <div ng-controller="studentController">
  <div>
     显示条数: <input type="text" ng-model="num" /><br />
     名称:<input type="text" ng-model="username" /><br />
     任何查询 : <input type="text" ng-model="anySearch" />
    工资之上:<input type="text" ng-model="money" />
  </div>
  
  <div ng-repeat="item in studentlist | limitTo:num|orderBy:‘-id‘ |filter:{‘name‘:username} |filter:anySearch |filter:{‘salary‘:money}:compareMoney">
   id:{{ item.id }} 名称:{{item.name}}  工资:{{item.salary}} 日期:{{item.birthday}}
  </div>
 </div>
<script src="js/angular.min.js"></script> 
<script type="text/javascript">
  var myApp = angular.module("myApp",[]);
  myApp.controller("studentController",function($scope,studentFactory){
   $scope.num=4;
   studentFactory.getStudentList($scope);
   $scope.compareMoney=function(a,b){
    return a>=b;
   }
  })
  
  myApp.factory("studentFactory",function($http){
   var factory={};
   factory.getStudentList=function(obj){
    $http.get("/student").then(function(data){
     obj.studentlist = data.data;
     console.log(data.data);
    }).catch(function(){
     console.log("error");
    });
   }
   return factory;
  })
  
</script>
</body>
</html>

angular过滤器

原文:http://www.cnblogs.com/Smile-Lee00/p/7116090.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!