Implementing an Angular 2 Table Filter

  • In the post, I want to show you how to implement a table filter in Angular.
  • The guide walks you through the creation of a table filter in Angular 2.
  • Implementing an Angular 2 Table Filter
  • It’s no secret that tables are popular, so it would help if you could create a filter for them.
  • Logic dictates that a filter for the table is pretty handy.

It’s no secret that tables are popular, so it would help if you could create a filter for them. This guide walks you through the creation of a table filter in Angular 2.

@haleyjason: Implementing an Angular 2 Table Filter: #angularjs

In this post, I want to show you how to implement a table filter in Angular.

The code can be found on GitHub.

A table in your application is maybe one of the most used controls. So, logic dictates that a filter for the table is pretty handy.

You can achieve this using a pipe:

This pipe takes an array if items and checks if the field which is also a parameter on a single items contains the value the user types. It returns the array of matching items.

The Pipe is available through the name “filter”.

After implementing this, the pipe has to be registered on a module to make it available in our application. Could be your application module or if you have one, a shared module. In case of the shared one: Do not forget to export it. 

In the template, you have to add an input to a form to display a field to the user where the searchstring can be typed. After this, the pipe has to be applied and the searchstring has to be databound in the template. 

Implementing an Angular 2 Table Filter