search

Home  >  Q&A  >  body text

angular.js - How does the ngRepeat directive in angular split the scope and copy the template?

Just two questions

1. ngRepeat will clone the template and then display each element in the array separately. So how does it do it? Is it to assign the scrope of each template instance to an array element?

2. How do I clone these templates and then dynamically bind the data binding, instructions and other things of the templates to them?

伊谢尔伦伊谢尔伦2815 days ago572

reply all(1)I'll reply

  • 我想大声告诉你

    我想大声告诉你2017-05-15 16:54:12

    The repeat instruction watches the array (or object), and then loops through each item:
    Use $transclude to get new content (already bound), and transclude will create a new scope, which is the scope used in repeat.

    You can find it in the source code of repeat https://github.com/angular/angular.js/blob/master/src/ng/directive/ngR...

    reply
    0
  • Cancelreply