My problem is that a html element needs to be replaced with a directive on event call. So i am calling a function in my controller on click event and appending the angular element at the desired position, that angular element is a directive so i need to do something to make it recognizable as directive. I have tried $compile but that doesn't work at controller level.
My controller Code
angular.element(document.body).append("<annotation></annotation> ");
My Directive code
app.directive("annotation", function($compile){
var linker = function(scope,element, attrs){
element.html("Done "+attrs.content);
if(attrs.content){
$(element).tooltipster({
content: $("<button class=\"btn btn-primary\">Highlight</button>"),
animation: 'fade',
delay: 200,
interactive: true,
theme: 'tooltipster-default',
touchDevices: false,
trigger: 'hover'
});
}
$compile(element)(attrs);
}
return {
restrict : "E",
template: '<div class="highlightor"></div>',
replace : true,
link : linker,
scope: {
content: "="
}
};
});