Create a Filter with AngularJS

Lukas Ruebbelke
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
Florian
~ 6 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
Sherrylicious
~ 6 years ago

Thanks, it solves the version issue :)

Paul
Paul
~ 6 years ago

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

JimTheMan
JimTheMan
~ 5 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
Harry
~ 5 years ago

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

marcio
marcio
~ 5 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