2016-08-31 63 views
2

標題可能看起來很奇怪,但即時通訊的內容基本上是this link正在做的事情。如何在ngFor之外使用* ngFor當前對象?

我正在尋找一種方法來使用當前迭代的person在範圍之外的<tr>

在他用ng-repeat-startng-repeat-end包括多標籤withing的ng-repeat.我如何能實現使用*ngFor withing Angular2相同的行爲的聯繫?

回答

5

我不得不使用<template>標籤,這使得迭代對象可以在其中訪問。

<template let-person ngFor [ngForOf]="people"> 
    <tr> 
     <td>{{person.name}}</td> 
     <td>{{person.gender}}</td> 
    </tr> 
    <div> 
     <span>{{person.details}}</span> 
    </div> 
</template> 

希望這會幫助別人

+0

你能提供爲什麼這個作品的鏈接,角文檔?關於使用HTML 5模板標籤的信息:https://angular.io/docs/ts/latest/guide/structural-directives.html#!#template –