This is something that's been bothering me for a while and I was wondering if people who have been working with Angular longer than me have come up with some satisfactory solution.
The problem is: how do you create a directive with an isolate scope (preventing accidental data access and allowing the user of the directive to easily provide data using the = mapping) while also giving the user the ability to customize the structure of the markup for the directive? If you simply use transclude true and isolate scope together, the transcluded scope should be a sibling of the isolate scope and therefore if you wanted to access anything from the controller of the directive you would have to first go up to the $parent and then probably down the $$firstChild. One quite bad solution I tried was to manually call the transcludeFn so I could set the scope of the transcluded content to the same as the isolate scope which allows me to easily use anything from there, but now I have to go through $parent again to get back to the upper containing scope of the directive. Another solution I found recently ( http://stackoverflow.com/questions/18541550/angular-directive-transclude-part-binding ) which seems to solve most of my problems is to assign functions and attributes to both the isolate scope and the transcluded scope (through $scope.$$firstSibling). Is this the best we can do? I guess you could give up the use of isolate scope to make things much simpler, but then your directive must expect that the data it uses is available in the scope chain with some hardcoded names. -- You received this message because you are subscribed to the Google Groups "AngularJS" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.
