[英]AngularJS SVG rendering order using ng-repeat
I'm having rendering order issues when trying to order or reverse a list of <g>
elements using ng-repeat
directive. 尝试使用
ng-repeat
指令排序或反转<g>
元素列表时出现渲染顺序问题。 Here's a plunkr to reproduce it: http://plnkr.co/edit/f2pgSq?p=preview 这是一个复制它的插件: http ://plnkr.co/edit/f2pgSq?p=preview
I'd like to use intensively Angular's orderBy
and filter
. 我想大量使用Angular的
orderBy
和filter
。 What am I missing? 我想念什么? Thanks in advance.
提前致谢。
The problem is ng-attr-y="{{y + (item.id - 1) * (h + 6)}}"
of <rect ng-repeat...>
. 问题是
<rect ng-repeat...>
ng-attr-y="{{y + (item.id - 1) * (h + 6)}}"
。
Change it to 更改为
ng-attr-y="{{y + $parent.$index * (h + 6)}}"
What you want is to use the $index
of the outer repeater instead of the id
since the id
s will get reversed. 您想要的是使用外部中继器的
$index
而不是id
因为id
会被反转。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.