我有我原來的工作代碼angular1如下:Angular2多個綁定錯誤
<div align="center" ng-show="showWords" >
<div ng-repeat="word in whichArray | limitTo:limitToMain" ng-if="$index % 2 == 0" class="row">
<div class="col" align="right" style="margin-right:1cm;"><h3>{{whichArray[$index]}}</h3></div>
<div class="col" align="left" style="margin-left:1cm;"><h3>{{whichArray[$index + 1]}}</h3></div>
</div>
</div>
當我嘗試將其轉換成angular2代碼如下:
<div align="center" *ngIf="showWords" >
<div *ngFor="let word of whichArray | limitTo:limitToPresent" *ngIf="$index % 2 == 0" class="row">
<div class="col" align="right" style="margin-right:1cm;"><h3>{{whichArray[$index]}}</h3></div>
<div class="col" align="left" style="margin-left:1cm;"><h3>{{whichArray[$index + 1]}}</h3></div>
</div>
</div>
我得到Can't have multiple template bindings on one element. Use only one attribute named 'template' or prefixed with *
錯誤。我創建了一個名爲limitTo的管道。
如何解決這個問題?
Angular2不要有$指數其唯一指標 –