One day, using
in your directive configuration might get you a :
Error: Template must have exactly one root element. was:<your root element>…
error whether you’re providing a template string or loading through templateUrl. I went back and double checked my HTML and it looks like I indeed had only a single root element in my template but lo and behold, that root element was followed by an HTML comment like:
<div>…</div><!– This is an html comment–>
From the point of view of Angular I indeed had sinned. Removing the comment fixed the issue. What to remember here is that first, don’t create sibling to your root element in your template files or strings, and second, make sure comments are within that root element or removed.