我正在使用以下模板:
所以它会产生以下错误:
我正在使用以下模板:
<ul [ngClass]="{dispN: !shwFilter,'list-group':true,'autoS':true,'dispB':shwFilter,'myshddw':true}" style=";display: none">
<li *ngIf="itsNotF && itsNotF.length" [ngClass]="{bgDFF: !colps[j],'list-group-item':true}" *ngFor="let valm1 of itsNotF;let j=index;" (click)="togFltr(j)" style="padding: 0;background: #fff">
<div *ngIf="valm1 && valm1.type=='1'">
<h5 style="padding:8px;margin: 0;">{{valm1['header']}}</h5>
<p style="margin: 8px;">{{valm1['body']}}</p>
<h6 style="padding:8px;margin: 0;">{{valm1['note']}}</h6>
</div>
<div *ngIf="valm1 && valm1.type=='2'" (click)="modlTxt=valm1;notREadVu(j)" data-toggle="modal" data-target="#myModal">
<h5 style="padding:8px;margin: 0;">{{valm1['header']}}</h5>
<h6 style="padding:8px;margin: 0;">{{valm1['note']}}</h6>
</div>
<div *ngIf="valm1 && valm1.type=='3'">
<h5 style="padding:8px;margin: 0;">{{valm1['header']}}</h5>
<p style="margin: 8px;">{{valm1['body']}}</p>
<h6 style="padding:8px;margin: 0;">{{valm1['note']}}</h6>
</div>
</li>
<li [ngClass]="{bgDFF: !colps[j],'list-group-item':true,'lgOt':true}" (click)="logout()">
<span class="title">Log Out <i class="fa fa-sign-out"></i></span>
</li>
</ul>
所以它会产生以下错误:
EXCEPTION: Template parse errors:
Can't have multiple template bindings on one element. Use only one attribute named 'template' or prefixed with * ("one">
<li *ngIf="itsNotF && itsNotF.length" [ngClass]="{bgDFF: !colps[j],'list-group-item':true}" [ERROR ->]*ngFor="let valm1 of itsNotF;let j=index;" (click)="togFltr(j)" style="padding: 0;background: #fff">
"): App@78:94
之前没有出现错误,我在升级到RC4后遇到了这个问题。
那么有什么解决方法,可以在不改变模板结构的情况下,在单个元素上应用多个模板绑定。
ngIf
和ngFor
都是结构型指令,它们不能同时存在于同一个元素上。为了解决这个问题,您可以查看此GitHub问题评论。 - Pankaj Parkar