2016-08-31 5 views
0

ルーキーウェブデベロッパーはこちら。角度2 ng崩壊は常に同じ<tr>

*ngForを使用して<tr data-toggle="collapse" data-target="#details">を作成しました。 私が経験することは、ある行をクリックすると常に同じdivが折りたたまれ、それに一致するものは折りたたまれないということです。

は、おそらく彼らはすべて同じIDを取得することで何かなければならない(?)

何を私が間違っているのとどのように私は私が探しているものを達成することができますか?

CODE:事前に

<template let-transaction ngFor [ngForOf]="accountTransactions"> 
    <tr data-toggle="collapse" data-target="#details"> 
     <td>{{transaction.time}}</td> 
     <td>{{transaction.description}}</td> 
     <td>{{transaction.amount}}</td> 
     <td>{{transaction.currency}}</td> 
    </tr> 
    <div class="container collapse" id="details"> 

ありがとう!

答えて

2

私は、現在の反復オブジェクトのインデックスと一緒に遊んとdata-targetのためにそれを配置し、試してみましたが、そのような折り畳み式<div>id用:

<template let-transaction ngFor [ngForOf]="accountTransactions" let-i="index"> 
    <tr data-toggle="collapse" [attr.data-target]="'#'+i"> 
     <td>{{transaction.time}}</td> 
     <td>{{transaction.description}}</td> 
     <td>{{transaction.amount}}</td> 
     <td>{{transaction.currency}}</td> 
    </tr> 
    <div class="container collapse" [attr.id]="i"> 

はそれが誰か助けていただければ幸いです

関連する問題