Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>EDIT</strong> - your <code>repeater</code> directive does nothing special - it is just a wrapper for <code>ng-repeat</code>. To understand why <code>repeater</code> is faster than manipulating the <code>DOM</code> from the controller, you need to understand how <code>ng-repeat</code> works, what are <code>compilation</code> and <code>linking</code> phases. AFAIR Miško Hevery - has a talk about this here <a href="http://www.youtube.com/watch?v=WqmeI5fZcho" rel="nofollow">http://www.youtube.com/watch?v=WqmeI5fZcho</a></p> <p>There are few things you are doing in your example that cause it to be slower than angular <code>ng-repeat</code></p> <ol> <li><p>Manipulating <code>DOM</code> in <code>controller</code> - <strong>don't do that</strong>! This practice is very bad! The reason <code>ng-repeat</code> is faster in this case is because it compiles the <code>DOM</code> once and only produces copies of the repeated element for each element in the array. In your case, you are creating element from string after the <code>DOM</code> has been rendered, then you modify the <code>DOM</code> structure by appending the element to the <code>document</code>, and after that, you are compiling the element you have just created against scope, which again modifies the <code>document's</code> <code>DOM</code>! You only need to compile the element once, and the append it to the parent (but do it in a directive - not in controller).</p></li> <li><p>If you want to have a faster implementation of <code>ng-repeat</code> (but with less features - like auto updating) then write a directive that would do almost the same thing but using single <code>template</code> element and modify the <code>document's</code> <code>DOM</code> only once.</p></li> </ol> <p>If you want to have better understanding how this works, I suggest reading <code>ngRepeatDirective</code> <a href="https://github.com/angular/angular.js/blob/master/src/ng/directive/ngRepeat.js" rel="nofollow">https://github.com/angular/angular.js/blob/master/src/ng/directive/ngRepeat.js</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload