I have some specific requirement. I have html pages for a functionality (like popup). I want that html to be rendered while changing my state. In this, my state specific HTML is different. Html which I want to render is should get render as a immediate child of body and it contains Angular tag like ng-click etc.
I want to load it by calling a function(manually).
This worked for me :
$http.get("/myTemplate.html").then(function(response) {
var raw_html = response.data;
$('body').append($compile(raw_html)(myScope));
});
But as per security concern, I can't use $('body').append (jquery apppend)
So I tried it from pure javascript :
$http.get("/myTemplate.html").then(function(response) {
var raw_html = response.data;
var element = document.createElement("div");
element.className = 'myClass';
element.innerHTML = raw_html;
document.body.appendChild($compile(element)(currentScope));
});
But what $compile return is not compatible with appendChild.
Can directive help me in this case?