我无法弄清楚为什么我的ngswitch无法正常工作。
<div [ngSwitch]="notification.type">
<div *ngSwitchWhen="'videoready'">
<p>Video Goes Here</p>
<p item-right>{{notification.added | date:'MMM'}}</p>
</div>
<div *ngSwitchWhen="'friendrequest'">
<p>Friend Request</p>
<p>{{notification.added | date:'MMM'}}</p>
</div>
<div *ngSwitchDefault>
<p>{{notification.message}}</p>
<p item-right>{{notification.added | date:'MMM'}}</p> <!-- adding the date pipe here BREAKS everything -->
</div>
</div>
通知在默认情况下肯定有added
个日期,它与其他日期对象相同。
另一个奇怪的事情是:如果我离开ngSwitchDefault
并注释掉其他人(因此只剩下默认值),那么日期管道工作正常。
这就好像ngSwitch一次匹配2个状态,并且......迷茫。
<div [ngSwitch]="notification.type">
<!-- leaving the others out works just fine -->
<div *ngSwitchDefault>
<p>{{notification.message}}</p>
<p item-right>{{notification.added | date:'MMM'}}</p>
</div>
</div>
答案 0 :(得分:1)
这是一个已知问题https://github.com/angular/angular/issues/5169
*ngSwitchDefault
中的管道目前无效。