Angular filters. Create your own filters

Главная » Tutorials » JavaScript » Angular filters. Create your own filters

In this tutorial we’ll discuss filters in angular. Angular has got several build-in filters. Also we will create our custom filter with filter method.

There are the list of build-in filters below:

  • uppercase formats string to uppercase.
  • lowercase formats string to lowercase.
  • number formats a number to string.
  • limitTo limit input of data based of specified number.
  • date formats date to specified format.
  • currency formats a number to currency.
  • filter chooses elements from the specified array.

As you understood from last lessons, filters were written after straight line.
Through a two-way data binding in angular we can use filters with different events – for example, filter by click or filter by user input. In examples it is sortByName filter and filter with selectPlayers model (live search) accordingly.

But like any framework, angular concepts are developers can expand opportunities of build in functionality. In our case it is creation of custom filters. For this purpose angular has got filter method. It has got two parameters – filter name and function, which will filter data.

Подписаться на рассылку

Будьте в курсе - получайте последние статьи на свой email

Ваша подписка успешно оформлена

Pin It on Pinterest

Share This