I\'m trying to build a directive that takes care of adding more directives to the element it is declared on. For example, I want to build a directive that t
Try storing the state in a attribute on the element itself, such as superDirectiveStatus="true"
For example:
angular.module('app')
.directive('superDirective', function ($compile, $injector) {
return {
restrict: 'A',
replace: true,
link: function compile(scope, element, attrs) {
if (element.attr('datepicker')) { // check
return;
}
var status = element.attr('superDirectiveStatus');
if( status !== "true" ){
element.attr('datepicker', 'someValue');
element.attr('datepicker-language', 'en');
// some more
element.attr('superDirectiveStatus','true');
$compile(element)(scope);
}
}
};
});
I hope this helps you.