Is it possible to somehow add directive as simple attribute in compile function and let angular handle compiling of added directive?
Provided example bellow obviously does not work, but my proper question would be, what is the cleanest way to achieve that?
var app = angular.module('app', []);
app.directive('testOne', function ($compile) {
return {
restrict: 'A',
priority: 10000,
compile: function (element, attrs) {
element.attr('test-two', '');
}
};
});
app.directive('testTwo', function () {
return {
restrict: 'A',
priority: 10,
compile: function (element, attrs) {
console.log(2);
}
};
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="app">
<div test-one></div>
</div>