Create a Filter with AngularJS

InstructorLukas Ruebbelke

Share this video with your friends

Send Tweet

We are going to learn how to filter our bookmarks based on the selected category. We will learn how to manage the current category in the controller as well as set the current category from the view. As a bonus, we will see how to dynamically apply a class to visually indicate what category is the currently selected category.

The code for this lesson can be found on Github. note: the tags correspond to the lessons.

Florian
~ 10 years ago

I stumbled upon the same problem.

There is no need to create an own filter-directive. This syntax worked for me.

     <div ng-repeat="bookmark in bookmarks | filter:currentCategory.name">
Sherrylicious
~ 9 years ago

Thanks, it solves the version issue :)

Paul
~ 9 years ago

Hi - Could someone please explain what ng-class="{'active' ... is doing? ty

JimTheMan
~ 9 years ago

Yeah, I don't really understand what "active class" means either and how you are telling it to make the label stay highlighted. Maybe it is a css class in the eggly.css that we don't see?

Harry
~ 9 years ago

How does the filter in ng-repeat manage to work when the currentCategory is set to null?

marcio
~ 8 years ago

Hey Guys!

A silly question... How can I set a default category, my ideia is show for example a "development" category instead of the all bookmarks.

If some one can give a hand I will appreciate.

Cheers, Marcio