Can someone explain the root cause behind the following behavior?
If a directive with isolate scope scope: {}
has a root element with ng-repeat
It does not just happen for ng-repeat, this seems to happen for any other directives that creates a scope like ng-if
as well. And it seems like, this is because the directive's isolated scope gets overwritten by the ng-repeat's child scope. And because of replace:true
option ng-repeat becomes a part of the directive source element i.e
and the child scope of ng-repeat is calculated from the ultimate parent scope MainCtrl
(Which appears to be wrong) and this causes the entire directive template to be bound to the child scope of controller and any interpolations are evaluated against that scope. Hence you see main controller's scope being expanded in the directive. This seems like a bug.