实在学习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:'yyyy年MM月dd日' }}</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 的代码原文链接:https://www.f2er.com/angularjs/149395.htmlangular.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怎么会被过滤出来的?