问题描述
我有一个简单的 ng-repeat-start 和 end 用例,并且工作正常,当我想添加内部 ng-repeat 时出现问题.这是我的代码
Hi I have a simple use case for ng-repeat-start and end and is working just fine, the problem appears when I want to add an inner ng-repeat.Here is the my code
<tr ng-repeat-start="obj in rows" >
<td ng-repeat="e in obj.row">{{e}}</td>
</tr>
<tr ng-repeat-end>
<td colspan="4">{{obj.description}}</td>
<tr>
td 元素中的内部 ng-repeat 不起作用,我在检查 html 源代码时看到了 ngRepeat 注释,但未创建 td 元素.
The inner ng-repeat into td element is not working, I'm seeing the ngRepeat comment when I inspect the html source code, but the td elements are not being created.
<!-- ngRepeat: e in obj.row -->
我丑陋的解决方法(假设我知道该向量的大小)是:
My ugly workaround (given that I know the size of that vector) is:
<tr ng-repeat-start="obj in rows" >
<td>{{obj.row[0]}}</td>
<td>{{obj.row[1]}}</td>
<td>{{obj.row[2]}}</td>
<td>{{obj.row[3]}}</td>
</tr>
<tr ng-repeat-end>
<td colspan="4">{{obj.description}}</td>
<tr>
推荐答案
我不确定你是否在使用 angular 1.1.6,因为 ng-repeat-start
和 ng-repeat-end
在 1.1.5 或 1.0.7 中尚不可用.
I am not sure whether you are using angular 1.1.6 or not since ng-repeat-start
and ng-repeat-end
are not available in 1.1.5 or 1.0.7 yet.
但是,您实际上不必使用新指令来实现这一点.您现在可以像这样简单地实现它:
However, you don't actually have to use the new directives to achieve that. You can simply implement it like this for right now:
<table>
<tbody ng-repeat="obj in rows">
<tr ng-repeat="e in obj.row">
<td>{{e}}</td>
</tr>
<tr>
<td colspan="4">{{obj.description}}</td>
<tr>
</tbody>
</table>
AngularJS 1.1.6 正式发布时,可以使用ng-repeat-start
和ng-repeat-end
重新实现.
You may use ng-repeat-start
and ng-repeat-end
to reimplement it when AngularJS 1.1.6 version is officially released.
这篇关于angularjs:ng-repeat-start 和 ng-repeat-end 带有内部 ng-repeat的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!