angularjs - Why does the ng-repeat directive create a child scope? -


Question: Why ng-repeat instructions make a hair scope?

I do not understand why this is the matter. Creating a new radius makes sense to an extent if you make a hair control clearly, but why would it automatically make one for every ng-repetition?

I think this confuses me because if you loop in JS, this does not mean that the code outside the loop can not enter any variable inside.

Example:

 For  (var x = 0; x and lt; 10; x ++) {var y = x} alert (y);  

DOM Javascript is not in the items in your archive ng-repeat It is necessary to have separate scope on the ING, which is tied to repeat DOM elements and they make a tree of scraps that some mirror structure (somewhat) of the page

Previously, this markup:

  & lt; Body ng-app = "myapp" & gt; & Lt; Div ng-repeat = "item in item" & gt; & Lt; P & gt; {{Item.name}} & lt; / P & gt; & Lt; / Div & gt; & Lt; / Body & gt;   

On the left side, the radius will spread on some more radius like:

  The root area of ​​the body is the scope of the div div   

(for example some estimated)

Comments

Popular posts from this blog

c# - Textbox not clickable but editable -

Matlab transpose a table vector -

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -