<!DOCTYPE html>
<html>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/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 = [
'c++',
'c#',
'c',
'.net',
'asp.net',
'mvc',
'AnjularJs',
'python',
'ruby'
];
});
</script>
<p>The list will only consists of names matching the filter.</p>
</body>
</html>In this code snippet you will learn how to filter array according to user input.
