ParentValueWatch is when a directive checks in its parent area the visibility of a change in some values ββand, therefore, must be changed itself.
Consider a simple directive
{ restrict:"AE", scope:{ foo:'=' } }
Now let's say in the parent scope, foo is an object.
$parent.$scope.foo = { bar:"zim" }
Each cycle of $digest , for the child $ region, it is necessary to check the value of the parent region foo and each of its properties.
If foo was really a big and deeply nested object, it would take a lot of time, so it takes so long.
Inside HTML, it might look like this:
<div parent-directive> <div foo-directive foo=bar></div></div>
One quick task is to βdryβ the values ββusing ng-init.
<div parent-directive> <div foo-directive ng-init='zug={bar:$parent.foo.bar}' foo=zug></div></div>
Now the value tied to the new object. You lose easy binding, but gain performance.
It is always a compromise.
source share