我有一个指令附加在动态生成的<table>
元素内的模板中。该指令在link
函数内操作该表的DOM。问题是,该指令在表格呈现之前运行(通过评估ng-repeat
指令)-然后表格为空。
问题:
如何确保指令在表格完全呈现后运行?
<table directive-name>
<tr ng-repeat="...">
<td ng-repeat="..."></td>
</tr>
</table>
module.directive("directiveName", function() {
return {
scope: "A",
link: function(scope, element, attributes) {
/* I need to be sure that the table is already fully
rendered when this code runs */
}
};
});
$http
请求还是硬编码数据? - Kalhan.Toress$routeProvider
配置中的resolve
属性来处理。 - Robert Kusznier$last
是否作为您操作的触发器。 - charlietfl