3
我在<tr>
元素中使用ng-repeat和指令。AngularJS - 在指令中的每個ng-repeat迭代中追加元素
HTML:
<tbody>
<tr ng-repeat="row in rows" create-table>
<td nowrap ng-repeat="value in row | reduceString>{{value}}</td>
</tr>
</tbody>
指令:
app.directive('createTable', function() {
return {
link: function (scope, element, attrs) {
var contentTr = scope.$eval('"<tr ng-show="false"><td>test</td></tr>"');
$(contentTr).insertBefore(element);
}
}
}
);
雖然我可以追加一個新<tr>
元素每次迭代中,我沒能得到執行的角度代碼它被添加到後DOM(例如<tr>
內的ng-show)。我錯過了明顯的東西嗎?