Senica Gonzalez
Senica Gonzalez

Reputation: 8182

Angular ng-repeat handlebars and <br /> tag

What is the proper way of doing this:

<tr ng-repeat="i in controller.model">
    <td>{{i.var1}}<br />{{i.var2}}<br />{{i.var3}}</td>
</tr>

When this renders, the <br/> is displayed as plain text.

Do I really have to define variables for each line that has a <br/> in it and use the $sce to set it as trusted? That seems awfully silly.

If you find the same question, please let me know what search phrase you used.

Edit

When the page is rendered in dev tools, the html looks like this:

<td><p class="ng-binding">Approved.&lt;br&gt;.&lt;br&gt;<br><br></p></td>

It is written like this in the page:

<td><p>{{i.ProgramInitiation}}<br>{{i.RejectReasonInitiation}}<br>{{i.RejectReasonOtherInitiation}}</p></td>

Strange. I'll play around with it as it obviously works in plunkr.

Upvotes: 0

Views: 668

Answers (1)

jarz
jarz

Reputation: 732

Looks fine to me. I tried this on a plunker.

<table>
      <tr ng-repeat="i in obj">
      <td>{{i.name}}<br/>{{i.lastname}}<br/>{{i.lastname}}</td>
      </tr>
</table>

Check it out here: http://plnkr.co/edit/BrfLvssZ7IZZzIj2JqRo

Upvotes: 2

Related Questions