Ng-Keydown-4

 

In this we can filter student name on ng-keydown directive.When we type in textbox its value bind to the searchValue variable and its value compare to dropdown value.

 
 
 
<!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-keydown="val=searchValue" /><br /> Select Student: <select size="5" ng-model="name" ng-options="p.name as p.name for p in students | filter:val">{{student.name}}</select> </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