I'm having a template with the following structure (address-contact-info.html):
<dd ng-repeat="contact in contactInfo | limitTo: displayedItems | orderBy:'desc'">
<span ng-transclude></span>
</dd>
And a directive:
{
templateUrl: 'address-contact-info.html',
restrict: 'A',
scope: {
contactInfo: '='
},
transclude: true,
link: function (scope, elem, attrs, ctrl, transclude) {
scope.displayedItems = 1;
}
};
I want to use the directive like this:
<div address-contact-info contact-info="tel">
<span>{{contact.number}}</span>
</div>
This means I want to access the ng-repeat scope inside my transcluded elements, but I don't know how to do that.
Do you have any idea how to achieve this, or is there a better way to do that?
Thanks for your help!
Update Here a plunker: http://plnkr.co/edit/4DYEUhHAPuJOLyG9omCT
Update
I found a solution that works for me, though I still have one problem. The elements I want to transclude in the template have their own directives which require a parent directive.
Now when I call the transcludeFn inside my linkFn, I get the following error:
Error: [$compile:ctreq] Controller 'editableGroup', required by directive 'editable', can't be found!
http://plnkr.co/edit/zriVyS7MzheSI8jcYM5d
In this plunker I haven't included the other directives, but I get a transcludeFb related error as well.
Cannot set property 'nodeValue' of undefined