Angular 用于突出显示单词的过滤器)在星号内以粗体显示

Angular filter for highlighting word(s) inside of asterik to with bold

我想输入*this is a sentence *并得到this is a sentence作为输出。

我看过 https://github.com/Hypercubed/angular-marked,但这提供了太多我不想要的选项(例如标题)。

有什么帮助吗?

我在这里创建了一个演示过滤器,用于将 text 转换为 <strong>text</strong>http://plnkr.co/edit/cQjytfvsT1Qu9ygjfEHz?p=preview

app.filter('asteriskToBoldFilter', function($sce){
  return function(val) {
    var matches = val.match( /\*(.*?)\*/g );
    if(matches){
      matches.forEach(function(line){
        var newline = line.replace('*', '<strong>').replace('*', '</strong>');
        val = val.replace(line, newline);
      })
    }
    return $sce.trustAsHtml(val);
  };
})