You can set the template in the directive. Each time you start the link function, you change the template. The first element <hx>
in your code has no template, so nothing appears. The second will use the pattern from the first (h1), and the third will use the pattern from the second (h1 again).
transclude
:
link: function(scope, element, attrs, ctrl, transclude) {
transclude(scope, function (clone) {
const header = angular.element('<h' + attrs.level + '></h' + attrs.level + '>');
header.append(clone);
element.append(header);
});
}
clone
. , ( clone
), hx
.
http://plnkr.co/edit/ED7NU8NmZ1g3G8efQNlu?p=preview