单击时运行ng repeat(当ng show为true时)
Run ng-repeat on-click (when ng-show is true)?
我有一个用ng-repeat
填充的表。表格有100行,如果你点击任何一行,就会显示新的表格,(带有ng-show
)对产品有更深入的描述。但ng-repeat
速度较慢,在页面加载时生成101表,这降低了我的web应用程序的性能。有没有一种方法,使用angular(没有外部库),只在用户单击某行时运行ng-repeat
(ng-show
为true)?
注意:每个隐藏表都是唯一的。
这是我的html表格:
<tbody>
<tr ng-repeat-start="car in sortedCarList" ng-click="showTable(car)">
<td><a target="_blank" href="{{car.carLink}}">{{car.name}}</a></td>
<td>{{car.review}}</td>
<td>{{car.rating}}</td>
<td>{{car.fiveStarPercent}}</td>
<td>{{car.recommended}}</td>
<td>{{car.price}}</td>
</tr>
<tr ng-repeat-end ng-show="modelRow.activeRow==car.name && showDetails && car.allReviews.length!=0" class="hidden-table">
<td colspan="6">
<table class="table table-striped table-bordered table-condensed table-hover">
<thead>
<tr>
<th>Year</th>
<th>Reviews</th>
<th>Rating <span class="fiveStar">/5</span></th>
<th>Recommended</th>
<th>Reliability Rating</th>
<th>Performance Rating</th>
<th>Running Costs Rating</th>
</tr>
</thead>
<tbody ng-repeat="rev in car.allReviews">
....
尝试使用ng-if
而不是ng-show
来切换嵌套表。这应该会延迟嵌套表中的任何ng-repeat
,直到它显示出来。
相关文章:
- 如果语句为true,则对一个或多个ng进行角度检查
- 在ng repeat中使ng disabled为true
- 为什么我的html节点保持类ng隐藏属性ng show=true
- 如果值为true,AngularJS将更新ng模型
- 如何将 ng-show 与控制器中返回 true/false 的函数一起使用
- 如何使用带有替换的模板覆盖/补充指令中的ng类:true
- 为什么ng-change总是从模型中传递“true”
- AngularJs ng显示当列表中的某一项在一行中为true时
- angular I只能设置'true'on'ng-if'但我可以't设置`false'
- 只有$touch为true时才会显示angular ng消息
- 单击时运行ng repeat(当ng show为true时)
- angular ng show即使设置为true也会显示内容
- ng使用内联编辑重复,如何使第一个(或最后一个)元素的editmode=true
- Ng-if在ng-repeat中总是返回true
- 在ng-click中,复选框返回false而不是true
- 当AngularJS中ng-checked = true时,在页面加载时调用函数
- 嵌套ng-repeat中$last的别名总是返回true
- AngularJS ng重复筛选器:{visible:true}不遵循属性更改
- AngularJS复选框动态ng-true-value表达式
- Angular ng-repeat with bootstrap输入复选框,动态ng-model使用ng-true-va