AngularJs – Filter over a field & multiple filter

AngularJs provides great filtering options. We use the filter for filtering the collection of data according to user selection.
Following code filter the students’ data using the user entry in ‘query’ field. In this case the filter will apply to all fields in students’ data collection.

Search: <input ng-model=”query” />
<ul>
<li ng-repeat=”st in students | filter:query“>

<p></p>
</li>
</ul>

Angular provides specific field level filtering. Following sample displays the students whose status is ‘Pass’
<ul>
<li ng-repeat=”st in students | filter:{Status: ‘Pass’} “>

<p></p>
</li>
</ul>

Moreover, we can perform multiple filtering in the same collection. Following sample shows how we can filter the students whose status is ‘Pass’ using user input

Search: <input ng-model=”query” />
<ul>
<li ng-repeat=”st in students | filter:{Status: ‘Pass’}| filter:query “>

<p></p>
</li>
</ul>

Advertisements

About ambilykk

I am a Technology Evangelist on Microsoft Technologies. I am carrying the passion on Microsoft technologies specifically on web technologies such as ASP .Net and Ajax. My interests also include Azure and Visual Studio. Technology adoption and learning is my key strength and technology sharing is my passion.
This entry was posted in AngularJs, HTML5 and tagged . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s