我正在生成一个呈现如下的 HTML 表格:
<table id="#webappname">
<tr ng-repeat="data in d">
<td>1 {{data}}</td>
<td>2 hey !</td>
</tr>
</table>
为了生成这个,我使用了 angular.element("#webapp").append("<table [...]</table>");
我希望表中的 Angular js 模板由 Angular 解释(有点像 jQuery.live()
)。我应该使用什么?
最佳答案
你应该编译它并将它链接到一个范围:
var table = angular.element("<table [...]</table>");
$compile(table)($scope);
angular.element("#webapp").append(table);
关于javascript - 使用 Javascript 生成 HTML,然后用 Angular js 解释它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21210858/