Angular
  • Introduction
  • Angular Command
  • Oshop Project
    • Oshop Tips
    • Product Management Module
  • Redux
  • Angular Tips
    • Communicate with Angular components outside of Angular
    • Safe Pipe
    • Highlight attachment file
    • Set CSS background-image value in Angular
  • Angular DatePicker Tips
  • Angular 6 Breadcrumb
Powered by GitBook
On this page

Was this helpful?

  1. Angular Tips

Highlight attachment file

Using RegEx replace with callback function

  const attachmentRex = /(?:Attachment[:\s]*)(.*)/gm;
  msg.emailBody = msg.emailBody.replace(attachmentRex, (original, matched, index)=>{
    let docIndex = this.searchAttachment(matched);
    let attachmentPrex = original.split(' ')[0];
    return attachmentPrex + ' <span id="attachmentDiv" class="attachment-highlight" onmouseenter="showPreview(event,'+docIndex+')">' + matched +'</span>';
  });
PreviousSafe PipeNextSet CSS background-image value in Angular

Last updated 5 years ago

Was this helpful?