Angular performance in ng-repeat

I ran into the performance problem of the ng-repeat directive, I displayed the PDFFields form using the ng-repeat directive, somehow it stops my browser. But when I use track at $ index and limitTo: 1 together in the same ng repeat, it works great and improves rendering speed. I can’t understand the logic of this, but it works unusually fast :)

  • This works faster and is fine for me, also limitTo: 1 does not work, some of the way it associates the constraint with $ index and stops the problem with the browser.

        <div ng-repeat="friend in friends track by $index | limitTo:1">
                  {{ friend.id }} &mdash; {{ friend.name }}
                </div>
    
  • if we use limitTo before the track at the index $ index, than the angular js limit behavior, which is understandable, usually behaves [/ p>

      <div ng-repeat="friend in friends | limitTo:1 track by $index">
                      {{ friend.id }} &mdash; {{ friend.name }}
                    </div>
    

OR

        <div ng-repeat="friend in friends | limitTo:1">
                      {{ friend.id }} &mdash; {{ friend.name }}
                    </div>

, . jsfiddle http://jsfiddle.net/neglingeyes/G6q84/

+4
2

ng-repeat post-repeat. , , , , - - , , , ng-repeat. , - - , "" , , . , . - .

? , ? , .

- friend in friends track by ($index | limitTo:1) ( " ?";-)) limitTo , $index. angular , , , .

0

:

ng-repeat dom node dom node, ; ng-repeat, , , , . $index, DOM.

, - http://www.reddit.com/r/angularjs/comments/2cvo16/speeding_up_angularjs_with_simple_optimizations/

0

Source: https://habr.com/ru/post/1535555/


All Articles