Reputation: 1114
I have the code:
htmlObject = '<div status-box></div>';
template = $compile(htmlObject)($scope);
$scope.$digest();
console.log(template);
var templateAsHtml = template.html();
console.log(templateAsHtml);
and the output: from the first console.log:
{0: <div status-box="" class="ng-scope"></div>, length: 1}
and from the second:
''
It seems like the moment I call .html it just not converting it and it is empty.
Upvotes: 1
Views: 958
Reputation: 13866
When you ask for .html()
of an element you will get the innerHTML
of it. Since '<div status-box></div>'
has no child nodes the behavior is correct. If you want to return the HTML including the object itself you need to use outerHTML
function.
var templateAsHtml = template[0].outerHTML;
console.log(templateAsHtml);
See docs:
Note: the [0]
is used to access the vanilla JavaScript object inside of your wrapper object.
Upvotes: 4