I have the following scenario: A transclude directive with isolated scope which has a controller attached in it:
angular.module('app', [])
.directive('hello', function() {
return {
controller: function($scope) {
$scope.hello = "Hello World";
},
restrict: 'E',
replace: true,
transclude: true,
template: '<div class="hello" ng-transclude></div>',
scope: {}
};
});
I'm looking forward to access the directive's controller from the transcluded elements:
<hello>
<h1>Hello Directive</h1>
<p>{{ hello }}</p>
</hello>
However this doesn't seems to be possible. I tried accessing hello
with $parent
and $$nextSibling
.
Is there any solution to this scenario? I'm not able to put the controller in wrapper around the directive instance.
I created a codepen to demonstrate this behaviour: http://codepen.io/jviotti/pen/ktpbE?editors=101