Line break in variable output

Hi all,

It’s probably a simple question, but I can’t find the answer. I have an object in my page (a restaurant), and it has a description field. The field is a big piece of text, and can contain some simple markup, like line breaks (<br>, or </p>).

However, when I display it like {{restaurant.description}}, the <br>s are displayed as is. If I replace them with \n, it also doesn’t work, the \n isn’t handled. So, my question is: how do I handle line breaks in variable output?

Thanks,

Erik

There are two options:

Using the pre tag

it preserves both spaces and line breaks. You will have to remove the tags inside but maybe this is not what you want.

Using ng-bind-html: from docs

Evaluates the expression and inserts the resulting HTML into the element in a secure way.

I’ve now used the ng-bind-html, and that works wonderful, thank you!