How to filter iron list in polymer 1.0?

The dom-repeat element offers a filter attribute.

Is there a similar way to filter using iron-list ?

For example: Given a list of people, I want to filter out births in a specific city.

+7
polymer
source share
1 answer

Since iron-list , unfortunately, does not offer a filter attribute, there is no declarative template to make this possible.

You can either implement your own simple list item using the dom-repeat filter property. (With overlay elements coming back in future releases, you can expand the iron-list ).

However, the best practice that I now see is to use a computed property:

 <template> <iron-list items="[[filterItems(items)]]" as="item"> ... </iron-list> </template> <script> Polymer({ ... filterItems: function (items) { return items.filter(function (item) { // Array.prototype.filter return item.priority > 8; // Filter condition }); } }); </script> 
+10
source share

All Articles