我有一个字符串,可以像
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged
Run Code Online (Sandbox Code Playgroud)
现在,在这里我有一个json,它有字符串开始和结束偏移,我想突出显示.现在,我使用的逻辑是这样的 -
$scope.highlightHTML = function(content, startoffset, endoffset) {
var className = 'mark';
console.log(content.substring(startoffset, endoffset));
return content.replace(content.substring(startoffset, endoffset), '<span class="' …Run Code Online (Sandbox Code Playgroud)