【发布时间】:2014-01-01 07:16:20
【问题描述】:
我正在使用 ng-repeat,其中有一个 div,其中 ng-include 在 json 数组上以区分包含的相同模板的范围,但是当数组大小增加时,这种方法会减慢页面的加载速度。任何人都可以提出一种提高渲染速度的方法或替代方法吗?我的方法在小提琴中得到了体现。
<script type="text/ng-template" id="/toBeIncluded.html">
This is a partial with something unique:
<input ng-model="partialVar.val" />
</script>
<div ng-controller="MyCtrl">
<div ng-repeat="partialVar in partialStuff">
<div ng-include src="'/toBeIncluded.html'">
</div>
</div>
<button ng-click="getValues()">Values</button>
<div>{{fvalues}}</div>
</div>
【问题讨论】:
-
使用 $timeout。看我的回答。
标签: angularjs angularjs-ng-repeat