您可以使用tbody标签将多个tr分组在一起,并使用ngRepeat对其进行循环。
http://jsfiddle.net/RkCMr/4/
<div ng-app="challenge"> <h3>how can I refactor it out using ng-repeat?</h3> <table ng-controller="ctrl"> <thead></thead> <tbody ng-repeat="item in collection"> <tr ng-click="showing=!showing"> <td>click</td> <td>{{item}}</td> </tr> <tr ng-show="showing"> <td>--></td> <td>comment {{item}} <a tooltip="a tooltip comment {{item}}"> <i ></i> </a> </td> </tr> </tbody> </table> </div>顺便说一句,看来您的代码仍处于Jquery的处理方式中。即使您已将它们放入指令中。如上面的示例所示,完全不需要指令,并且不使用JQuery。



