Javascript 角度模板参考投掷误差
我有两个数组变量,需要呈现相同的html内容Javascript 角度模板参考投掷误差,javascript,angular,typescript,Javascript,Angular,Typescript,我有两个数组变量,需要呈现相同的html内容 notification = [...] disruptionNotification = [...] 下面是我的HTML <ng-container *ngFor="let notification of notifications; let i = index"> <ng-container *ngTemplateOutlet="notification"></ng-container>
notification = [...]
disruptionNotification = [...]
下面是我的HTML
<ng-container *ngFor="let notification of notifications; let i = index">
<ng-container *ngTemplateOutlet="notification"></ng-container>
</ng-container>
<ng-container *ngFor="let notification of disruptionNotification; let i = index">
<ng-container *ngTemplateOutlet="notification"></ng-container>
</ng-container>
<ng-template #notification>
<tag-notification [type]="notification.type">
<ng-container *ngIf="notification.titleLink && notification.title; else bwcNotificationTitleOnly">
....
</ng-container>
</tag-notification>
</ng-template>
在*ngIf else子句中引用的任何元素都不能是任意组件,但必须是ng模板。您能否创建一个小提琴来重现该问题。在我的情况下,错误是因为我忘记了ngTemplateOutlet之前的*(星号)
This is Title
This is Title
This is disruptionNotifications
This is disruptionNotifications