Render text as html with angularJs

妖精的绣舞 提交于 2020-01-06 08:29:57

问题


How do I make the string to be rendered as HTML? When doing something like:

<div>
  {{ text }}
</div>

The output is just displayed at text meaning " ab "


回答1:


Regular expression:

var pattern = new RegExp(keywords.join('|'), "g");
var result = text.match(pattern);

Rending a string as HTML:

<div ng-bind-html="text"></div>

P.S: Since these are two different questions, next time you should post them separately.



来源:https://stackoverflow.com/questions/22366518/render-text-as-html-with-angularjs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!