Andrew2016-04-16 16:23:08
Andrew, 2016-04-16 16:23:08

Angular, is it possible to filter by radiobutton?

There is some model like

Items: [{Name:"First",  Categories:[1,2]},
{Name:"Second", Categories:[1]},
{Name:"Cats", Categories:[2,3]},
{Name:"Dogs", Categories:[3]}//итд

Categories:[{Id:1, Name:"SomeItems"},
{Id:2, Name: "SomeItems2"},
{Id:3, Name: "Anything"//итд

Items is displayed as a list, Categories as radio buttons.
Is it possible to make the built-in filters so that when you click on the radio button, only those items that have the corresponding id in the Categories array are displayed? Or do I need to write a custom filter?
I would be grateful for the right direction, how to determine the selected radiobutton and filter the display results

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Maxim Yakupov, 2016-04-16

It seems that it is possible to propagate radio buttons using *ngFor="#btn of buttons", by hanging on the button selection event a call to the rButtonSelected(#btn.Categories)component method that will change the array field of the component showingCategories. And the category display block will use the same *ngFor="#c of showingCategories"to display the current displayed categories.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question