Hide / Show and Filter


#1

Hi!

I am pretty new to ionic 2. I am wondering how can I hide elements depending on the selected filter.

I have some filters and ion-cards in my ion-content.
What I want to do is to hide the ion-cards that don’t qualify the requirements of the selected filter.
Can somebody help me or give me a direction on how this should be done in ionic 2?

I am using typescript and ionic 2 components btw.

Thanks!


#2

There are two ways to do this:

[hidden]=“filter == ‘bla’”

*ngIf=“filter == ‘bla’”


#3

Just a minor remark, the 1st expression hides/removes the element if the expression is true, and the 2nd keeps the element if the expression is true. Thus to be equivalent the second line would have to be something like

*ngIf="filter != 'bla'"

or whatever inequality operator is expected in TS :slight_smile: