AngularJS and IE8, directive that compiles HTML

I have a directive that loads an article in HTML from a CMS via a REST API and a template file what should be compiled together with the article.


element.html(templateLoaded.data);
scope.document = theLoadedArticle;
$compile(element.contents())(scope);

This worked in most browsers except our old “friend” Internet Explorer 8. The reason is I have another directive in the loaded template file and I need to tell the DOM compiler about this (IE8 is cranky about non-html tags).

So, inside the template file I added:


<script type="text/javascript">
//Needed for IE8/9
document.createElement('my-directive');
</script>

Now it works. It could probably be done outside the template file as well.

Standard