Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/30.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
Javascript 角度模板参考投掷误差_Javascript_Angular_Typescript - Fatal编程技术网

Javascript 角度模板参考投掷误差

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>

我有两个数组变量,需要呈现相同的html内容

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