I am trying add HTML elements through javascript that has a directive:
document.getElementsByClassName("day-grid")[0].innerHTML = "<div ng-uc-day-event></div>";
or
var ele = document.createElement("div");
ele.setAttribute("ng-uc-day-event","");
document.getElementsByClassName("day-grid")[0].appendChild(ele);
Both results in adding the div to .day-grid. I am using a directive to load template from an external file into ng-uc-day-event. It works as expected when it is run from the HTML file, but it doesn't work when I run the above code from the developer console.
How do I make angularjs to call the directive or evaluate the element when I am adding the element to DOM, so that the template is loaded into div when it is inserted into .day-grid?
Below is the directive I am using:
ulcal.directive("ngUcDayEvent", function ($timeout) {
return {
restrict: 'A',
templateUrl: 'views/dayevent.html',
link: function (s, e, a) {
$timeout(function () {
s.$emit("ucDayEventLoaded");
})
}
}
});