Przemysław Zamorski Przemysław Zamorski - 4 months ago 27
TypeScript Question

Is it possible to have many cases for ngIF in angular 2 template

i have a list of months number like this:

months = ['1','2','3'...etc]

And i itterate over array in template :

<table *ngFor="let month of allMonthChannel" >
<months *ngIf =" something "></months>

The question is how i can display my months component when month value only be like 3,6,9,12. What i should i put instead "something " ?
Thanks for answers and sory for my english :)


A very simple solution could be using modulo, granted you really just need the months 3, 6, 9 and 12:

<table  *ngFor="let month of allMonthChannel"  >
    <months *ngIf="month % 3 == 0"></months> 

Plunker for a working example