Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在angular 2模板中是否可能有许多ngIF案例_Angular_Typescript_Angular2 Template - Fatal编程技术网

在angular 2模板中是否可能有许多ngIF案例

在angular 2模板中是否可能有许多ngIF案例,angular,typescript,angular2-template,Angular,Typescript,Angular2 Template,我有一个月数列表,如下所示: months = ['1','2','3'...etc] 并且我在模板中的数组上执行以下操作: <table *ngFor="let month of allMonthChannel" > <months *ngIf =" something "></months> </table> 问题是当月份值仅为3,6,9,12时,如何显示月份组件。我应该用什么来代替“某物”? 感谢您的回答,也感谢

我有一个月数列表,如下所示:

months = ['1','2','3'...etc]
并且我在模板中的数组上执行以下操作:

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

问题是当月份值仅为3,6,9,12时,如何显示月份组件。我应该用什么来代替“某物”?
感谢您的回答,也感谢我的英语:)

一个非常简单的解决方案可以使用,假设您真的只需要3、6、9和12个月:


作为一个有效的例子


可以使用一个非常简单的解决方案,假设您只需要3、6、9和12个月:


作为一个有效的例子


你在找吗?你在找吗?虽然你肯定给出了他要求的答案,但我认为提及NgSwitch指令对任何发现这个问题的人来说都是有用的,因为这个问题无法用简单的数学来解决。正确地工作。我是angular2和typescript的新手,我没有想到我可以在angular2中简单地使用数学。我是傻瓜:虽然你已经明确给出了他要求的答案,但我认为提及NgSwitch指令对任何发现这个问题的人来说都是有用的,因为这个问题无法用简单的数学来解决。正确地工作。我是angular2和typescript的新手,我没有想到我可以在angular2中简单地使用数学。我是傻瓜:p