The dom is not rendered when the output is written to the console. Using $timeout
, you can view the rendered content. MANY people say this is a hack. Regardless, it works. Here's what I changed, with the same result in both directives:
//after injecting $timeout in the directive:
$compile(container)(scope);
console.log('before');
console.log($('#template').children().text());
$timeout(function(){
console.log('before, in timeout:');
console.log($('#template').children().text());
},0)
Also, see this answer and check out the links within.