Reputation: 5
I have lots of questionnaire, and now I want to use *ngIf to filter which not to appear in some div.
the stupid way now I use is to sign individually
<div *ngIf = "questionNo!= '00' && questionNo!= '04' && questionNo != '21'">
...</div>
and I think there is better way like *ngIf= "questionNo != [00.01,02....]" but I try but in vain.
so I need your help~ thank you!
Upvotes: 0
Views: 47
Reputation: 32517
I would move that condition to component code into shouldShowSomething():bool
as it is much clearer and maintainable + can take arguments for eventual parametrization.
Upvotes: 1
Reputation: 10137
Either use &&
or ||
or:
*ngIf= "[00,01,02].includes(questionNo)"
*ngIf= "![00,01,02].includes(questionNo)"
Upvotes: 1