AngularJS中内置过滤器问题?

前端之家收集整理的这篇文章主要介绍了AngularJS中内置过滤器问题?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

实在学习AngularJS过滤器中遇到的问题

这个是页面代码

<!DOCTYPE html>
<html>
   <head>
      <Meta charset="utf-8" />
      <title></title>
      
   </head>
   <body  ng-app="myApp"  >
      
      
      <div ng-controller="ctrl01" >
         
         <h1>{{money | currency:''  }}</h1>
         <h1>{{birthday | date:'yyyyMMdd' }}</h1>
         
         
         <input ng-model="condition"  />
         <br />
         <input type="text" ng-model="cond_name" />
         <div  ng-repeat="user in ( users | filter:{name:cond_name} ) ">
               {{user.name}}--{{user.phone}}
         </div>
         
            <hr />
         
         <div  ng-repeat="user in ( users | filter:func ) ">
               {{user.name}}--{{user.phone}}
         </div>
         <hr />

         <div  ng-repeat="user in ( users | filter:condition ) ">
            {{user.name}}--{{user.phone}}
         </div>
         
      </div>

   </body>
   <script type="text/javascript" src="js/angular.min.js" ></script>
   <script type="text/javascript" src="js/filter_app.js" ></script>
   
</html>

这个是 filter_app.js代码
angular.module("myApp",[])
         .controller("ctrl01",function($scope,$rootScope){
         
            $scope.money=123111111;
            $scope.birthday= new Date();
            
            var  users=[
               {id:1,name:'cai10',phone:'456789',age:3},{id:2,name:'xiaogao2',phone:'12312ma3',age:5},{id:3,name:'laogao3',phone:'123123',age:7},{id:4,name:'laoma4',age:8},];
            
            $scope.users=users;
            $scope.cond_name="";
            
            
            $scope.func=function(user){
               
               return  user.age>3;
            }
         });
         

这是一个字符串过滤,当我输入4的时候,过滤结果是正确的

当我输入的是7的时候,第2个结果是怎么出来的,明显第二个中没有7怎么会被过滤出来的?
原文链接:https://www.f2er.com/angularjs/149395.html

猜你在找的Angularjs相关文章