I have compiled an element using the $compile service. If I add that directly to the DOM, it looks great and all of the bindings are correct. If I want that element as a string though, it shows {{stuffHere}}
instead of the bindings. Is there a way to get the html of the element after it's compiled?
$templateCache.put('template', '<div><div><div><span>content is {{content}}</span></div></div> </div>');
$scope.content = 'Hello, World!';
var el = $compile($templateCache.get('template'))($scope);
$('body').append(el);
alert(el.html());
http://plnkr.co/edit/1sxvuyUZKbse862PieBa?p=preview
The element appended to the body shows content is Hello, World!
The alert shows <div><div><span ng-binding>{{content}}</span></div></div>
What I would like to see out of the alert is <div><div><span ng-binding>Hello World</span></div></div>