Angular 6中管道荧光笔的问题

问题描述 投票:0回答:1

我有一个管道,突出搜索关键字

enter image description here

但是当我清除输入表格时,我的管道会突出显示一个单词中的每个字母。如何修复它?在这种情况下,文本为null

enter image description here

代码手稿

@Pipe({
name: 'highlight'
 })

export class HighlightSearch implements PipeTransform {

public transform(value: string, predicate: string): string {

return value.replace(new RegExp(predicate, 'gi'), `<mark>${predicate}</mark>`);
   }
}

HTML

<tbody>
    <tr *ngFor="let Slide of SlidesFinded;">
      <td>{{ Slide.idSlide }}</td>
      <td>NULL</td>
      <td [innerHTML]="Slide.textSlide | highlight: text"></td>

    </tr>
  </tbody>
angular typescript
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.