I have a code that dynamically create elements (the x
and the parentDiv
).
var x = document.createElement('myTag');
parentDiv.appendChild(x);
And I have a directive that looks like this:
.directive("myTag", function($compile) {
return {
restrict: "E",
replace: true,
template: "<span><img src='something/url/img.png'></img></span>"
}
})
How can I replace the myTag tag into that code in the directive? I am aware of using $compile so that the code outside of AngularJS can be covered under its scope but I do not know where to put that.