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 "

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top