How can I preserve new lines in an AngularJS partial?

前端 未结 4 1700
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-02 16:53

Within an AngularJS partial I am looping over a list of entries as follows:

4条回答
  •  情话喂你
    2020-12-02 17:23

    It is just basic HTML. AngularJS won't change anything about that. You could use a pre tag instead:

    {{ entry.content }}

    Or use CSS:

    p .content {white-space: pre}
    
    ...
    
    

    {{ entry.content }}

    If entry.content contains HTML code, you could use ng-bind-html:

    Don't forget to include ngSanitize:

    var myModule = angular.module('myModule', ['ngSanitize']);
    

提交回复
热议问题