Monday, 9 September 2013

Nested directives and transclusion

Nested directives and transclusion

I have a directive where I bind a property using:
scope: {modelVar: "="}
The directive template makes use of that variable:
<input ng-model="modelVar">
This works great, until I transclude this directive within another
directive. Then, the input directive lives in a child scope and the
binding with the parent stops working.
The solution I found around was to put modelVar inside some property in
the scope. But then, I need to add a controller to my directive and set up
my own two-way binding between this new property and the one that is
directly in the scope.
Is there a straightforward way to do it so I can avoid the two-way binding?
Please refer to the code here
http://plnkr.co/edit/FiyDYLlJQ9aq2KZm5mIg?p=preview

No comments:

Post a Comment