How to filter ng-repeat values according to ng-model using AngularJS ? Last Updated : 01 Aug, 2022 Suggest changes Share Like Article Like Report In this article, we will see how to filter the value of the ng-repeat directive according to the ng-model directive using AngularJS. The ng-repeat values can be filtered according to the ng-model in AngularJS by using the value of the input field as an expression in a filter. We can set the ng-model directive on an input field to filter ng-repeat values. The below illustrations describes the approach for the implementation. Example 1: Filtering input text ng-repeat values according to ng-model. This filter will show the names of only the matching city. HTML <!DOCTYPE html> <html> <head> <script src= "https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"> </script> </head> <body> <center> <h1 style="color:green;"> GeeksforGeeks </h1> <h3> Filter ng-repeat values according to ng-model </h3> </center> <div ng-app="app1" ng-controller="controller1"> <p>Type a city name in the input field:</p> <p> <input type="text" ng-model="testfilter"> </p> <p>Filter show the names of only the matching city.</p> <ul> <li ng-repeat="x in citynames | filter:testfilter"> {{ x }} </li> </ul> </div> <script> angular.module('app1', []).controller( 'controller1', function($scope) { $scope.citynames = [ 'Ahmedabad', 'Ajmer', 'Bhopal', 'Jaipur', 'Surat', 'Nagpur', 'Mumbai', 'Pune', 'Indore', 'Udaipur', 'Jodhpur', 'Jabalpur', 'Gwalior', 'Delhi', 'Lucknow', 'Banglore' ]; }); </script> </body> </html> Output: Example 2: Filtering input text ng-repeat values according to ng-model. This filter will show the names of only the matching programming language after capitalizing on each language by applying the filter. HTML <!DOCTYPE html> <html> <head> <script src= "https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"> </script> </head> <body> <center> <h1 style="color:green;"> GeeksforGeeks </h1> <h3> Filtering input text ng-repeat values according to ng-model </h3> </center> <div ng-app="app1" ng-controller="controller1"> <p> Type a programming language name in the input field: </p> <p> <input type="text" ng-model="testfilter"> </p> <p> Filter shows the names of only the matching programming language after capitalizing each language by applying filter. </p> <ul> <li ng-repeat= "x in programminglanguagenames| filter:testfilter"> {{ x |myfilter}} </li> </ul> </div> <script> var app = angular.module('app1', []); app.filter('myfilter', function () { return function (x) { var i, c, txt = ""; for (i = 0; i < x.length; i++) { c = x[i]; c = c.toUpperCase(); txt += c; } return txt; }; }); app.controller('controller1', function ($scope) { $scope.programminglanguagenames = [ 'cobol', 'pascal', 'ruby', 'php', 'perl', 'python', 'c', 'c++', 'java', 'html', 'css', 'javascript', 'basic', 'lisp', 'smalltalk', 'bootstrap' ]; }); </script> </body> </html> Output: Advertise with us Next Article How to filter ng-repeat values according to ng-model using AngularJS ? C chaitanyashah707 Follow Similar Reads How to fetch the details using ng-repeat in AngularJS ? In this article, we will see how to fetch the details with the help of the ng-repeat directive in Angular, along with understanding its implementation through the illustrations. AngularJS contains various types of pre-defined Directives, where most of the directives start with ng which denotes Angul 2 min read How to Filter Multiple Values in AngularJS ? AngularJS is one of the popular frameworks of many web developers to create dynamic single-page web applications. To make the application more and more dynamic, we can use the filtering of data feature to dynamically show the data to the user as per the input or selection. These provide a better use 6 min read How to get the value of radio button using AngularJS ? In this article, we will see how to get the value of the radio button using AngularJS, along with understanding the basic implementation through illustrations. The value of the checked radio button can be fetched with the help of the ng-model directive that helps to bind the data with the specific e 2 min read How to get form input value using AngularJS ? Given a form element and the task is to get the form values input by the user with the help of AngularJS.Approach: We are storing the data in the JSON object after the user enters it in the input element with the help of the Angular.copy(object) method. After that, data from the JSON object can be a 2 min read How to Filter an Array based on user input in AngularJS ? AngularJS is a JavaScript-based framework. It can be used by adding it to an HTML page using a <script> tag. AngularJS helps in extending the HTML attributes with the help of directives and binding of data to the HTML with expressions. Angular filters can be added in AngularJS to format data. 3 min read Article Tags : Web Technologies AngularJS AngularJS-Directives AngularJS-Questions Like