C# Corner
Tech
News
Videos
Forums
Trainings
Books
Events
More
Interviews
Jobs
Live
Learn
Career
Members
Blogs
Challenges
Certifications
Bounties
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Filter an Array Based on User Input
WhatsApp
Ajay Malik
Aug 01
2016
764
0
1
<!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
>
AngularJs
Up Next
Filter an Array Based on User Input