【问题标题】:AngularJS SVG rendering order using ng-repeat使用 ng-repeat 的 AngularJS SVG 渲染顺序
【发布时间】:2013-09-17 01:24:30
【问题描述】:

我在尝试使用 ng-repeat 指令对 <g> 元素列表进行排序或反转时遇到渲染顺序问题。这是一个重现它的 plunkr:http://plnkr.co/edit/f2pgSq?p=preview

我想集中使用 Angular 的 orderByfilter。我错过了什么?提前致谢。

【问题讨论】:

    标签: javascript angularjs svg angularjs-directive


    【解决方案1】:

    问题是ng-attr-y="{{y + (item.id - 1) * (h + 6)}}"<rect ng-repeat...>

    改成

    ng-attr-y="{{y + $parent.$index * (h + 6)}}" 
    

    您想要的是使用外部中继器的$index 而不是id,因为ids 将被反转。

    Demo

    【讨论】:

    • 糟糕,我应该看到的。谢谢!
    猜你喜欢
    • 1970-01-01
    • 2014-09-19
    • 2014-01-16
    • 1970-01-01
    • 2017-01-26
    • 1970-01-01
    • 1970-01-01
    • 2014-07-09
    • 1970-01-01
    相关资源
    最近更新 更多