AngularJS Input Filters Examples




AngularJS Input Filters

<!DOCTYPE html>
<html>
   <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js">
   </script>
   <body>
      <div ng-app="myApp" ng-controller="namesCtrl">
         <p>Type a letter in the input field:</p>
         <p><input type="text" ng-model="test"></p>
         <ul>
            <li ng-repeat="x in names | filter:test">
               {{ x }}
            </li>
         </ul>
      </div>
      <script>
         angular.module('myApp', []).controller('namesCtrl', function($scope) {
            $scope.names = [
               'Emma',
               'Olivia',
               'Sophia',
               'Isabella',
               'Joe',
               'Gustav',
               'Birgit',
               'Emily',
               'Abigail'
            ];
         });
      </script>
      <p>The list will only consists of names matching the filter.</p>
   </body>
</html>

Output