I encountered this error when trying to move clutter away into a directive.
function Ctrl($scope, $rootScope) {
}
angular.module('app', []);
angular
.module('app')
.directive('directive1', Directive1);
function Directive1() {
return {
transclude: true,
restrict: 'E',
replace: true,
scope: true,
template: '<ng-transclude></ng-transclude>'
};
}
angular
.module('app')
.directive('directive2', Directive2);
function Directive2() {
return {
transclude: true,
restrict: 'E',
replace: true,
scope: true,
template: '<directive1>Some content from directive1 \
<ng-transclude></ng-transclude> \
</directive1>'
};
}
angular
.module('app')
.controller('ExampleController', ExampleController);
function ExampleController() {
}
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="app" ng-controller="Ctrl">
<directive2>
Some content meant to deeply transclude into directive1
</directive2>
</div>
To me, it seems like a valid use case. Why would AngularJs not allow this? And is there any way this error can be overcome?