angularjs newline filter with no other html

后端 未结 7 1058
北恋
北恋 2020-12-07 14:14

I\'m trying to convert newline characters (\\n) to html br\'s.
As per this discussion in the Google Group, here\'s what I\'ve got:



        
相关标签:
7条回答
  • 2020-12-07 14:54

    An update to the filter with ng-bind-html currently would be:

    myApp.filter('newlines', function () {
      return function(text) {
        return text.replace(/(&#13;)?&#10;/g, '<br/>');
      }
    });
    

    and the noHTML filter is no longer required.

    white-space solution is having low browser support: http://caniuse.com/#search=tab-size

    0 讨论(0)
提交回复
热议问题