Ng-Keyup-3

 

In this we can filter student name on ng-keyup event.When we type in textbox its value bind to the searchValue variable and student will search from array of object using ng-repeat directive.

 
 
 
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Welcome to LearnKode - A code learning platform</title> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js"></script> </head> <body ng-app="clickExample"> <div ng-controller="ExampleController"> <b>Search:</b><input type="text" ng-model="searchValue" ng-keyup="val=searchValue" /> <div ng-repeat="student in students | filter:val">{{student.name}}</div> </div> <script> var app = angular.module("clickExample", []); app.controller('ExampleController', ['$scope', function ($scope) { $scope.students = [{ name: 'John' }, { name: 'Smith' }, { name: 'Allen' }, { name: ' Johnson' }, { name: 'Harris' }, { name: ' Williams' }, { name: 'David' }]; }]); </script> </body> </html>
Output