Archives / 2014 / February
  • AngularJS–don’t use self-closing div tags

    I had a piece of code that gave strange results in AngularJS. The issue was that I used a self closing <div /> tag instead of <div>…</div>. Self closing div tags are not supported in HTML5. The complete code can be found at and the plunker

    My wrong code was written as:

    <script id="paragraphTmpl.html" type="text/ng-template">
        <!-- comment line below to have the paragraphs render correctly --> 
        <div ng-bind-html="trustAsHtml(paragraph.Content)"/>
        <ng-include ng-repeat="paragraph in paragraph.Paragraphs" 
        <div ng-bind-html="trustAsHtml(chaptercontent.Content)"/>
        <ng-include ng-repeat="paragraph in chaptercontent.Paragraphs" 
    It works fine when jQuery is included, but not when you use the AngularJS JQLite implementation.
    When <div ng-bind-html="trustAsHtml(chaptercontent.Content)"></div> is used, the code works correctly.