Pass data to transclusion scope in Angularjs

210 Views Asked by At

I'm trying to pass data to transclude scope to make variable existing only in there. I mean I'm creating component:

.component('testComp', { 
    bind: { 
        collection: '<'
    },
    transclude: true,
    templateUrl: 'testcomptemplate.html',
    controller: TestCompController
});

With template:

<div>
    <ng-transclude ng-repeat="$item in $ctrl.collection"></ng-transclude>
</div>

And while using that component in another file I want to make $item variable available in it's transclude:

<div>
    <test-comp collection="someCollection">
        {{ $item.name }}
    </test-comp>
</div>

I've already tried making another component which would be transclude either or directive but still can't make it done. Anything what I could name progress was accessing to $item through $parent variable. Is this even possible in component?

0

There are 0 best solutions below