AngularJS String with newlines, shown without breaks

后端 未结 4 862
野趣味
野趣味 2020-12-14 05:54

In the database I\'m saving input from a textarea, where you can add breaks. But how to show them in a Angular view? For PHP this is nl2br().

Like

4条回答
  •  爱一瞬间的悲伤
    2020-12-14 06:24

    Googling angularjs nl2br yielded this result:

    AngularJS - Remove \n from data

    Namely the last answer which demonstrates how to replace new lines with
    using a filter. Combine that with ng-bind-html, as the unsafe version might not be currently available. You should probably convert the line breaks to
    when inserting them to database(makes more sense to me).

提交回复
热议问题