輸入過濾器能夠經過一個管道字符(|)和一個過濾器添加到指令中,該過濾器後跟一個冒號和一個模型名稱。
filter 過濾器從數組中選擇一個子集:html
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> <script src="https://cdn.staticfile.org/angular.js/1.4.6/angular.min.js"></script> </head> <body> <div ng-app="myApp" ng-controller="myCtrl"> <p>輸入過濾器</p> <p><input type="text" ng-model="test"></p> <ul> <li ng-repeat="x in names|filter:test|orderBy:'country'"> {{(x.name|uppercase)+','+x.country}} </li> </ul> </div> <script> var app=angular.module('myApp',[]); app.controller('myCtrl',function($scope){ $scope.names=[ {name:'star',country:'china'}, {name:'star1',country:'us'}, {name:'star2',country:'un'} ] }) </script> </body> </html>