I'm using Angular 1.29 and Chrome.
I have some text like
<p>Text <strong> bold </strong> </p>
And I need to turn it into an element
, because the library that I'm using, html2canvas, needs to be sent one.
So I've tried this, which I took from this answer
var div = document.createElement('div');
div.innerHTML = $scope.presData.text;
var element = div.firstChild;
html2canvas(element,{
onrendered:function(newCanvas){
document.getElementById("newPresentation").appendChild(newCanvas);
}
});
Where my text is in $scope.presData.text
,
But that didn't work. This creates a canvas with a width and height of 0.
and HTML elements nested within. You can then query the children of the container to get the element directly. OP's code should be working, at least the element creation portion.
– Aweary Dec 15 '14 at 21:05` element stack. If you wanted just the `
` and `` elements, you'd call `HTMLStringContainer.firstChild`