I have the following scenario: a transclude directive with an isolated area in which there is a controller:
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 look forward to accessing the directive controller from the moved items:
<hello> <h1>Hello Directive</h1> <p>{{ hello }}</p> </hello>
However, this is not possible. I tried to access hello using $parent and $$nextSibling .
Is there any solution for this scenario? I can not put the controller in a wrapper around the directive instance.
I created codepen to demonstrate this behavior: http://codepen.io/jviotti/pen/ktpbE?editors=101
source share