I am using Angular 12 and I have a method that takes a screenshot of an element. It works, but I want to call it from a service.
Here is the code:
import html2canvas from 'html2canvas';
import { saveAs } from 'file-saver';
...
takesshotOfElement(elementId: any) {
    const element = document.getElementById(elementId) as HTMLCanvasElement;
    html2canvas(element).then((canvas) => {
      canvas.toBlob((blob: any) => {
        saveAs(blob, "filename.png");
      });
    });    
}
How do I go with putting this method in a service so I can call the service instead and make the method cleaner?
 
     
     
    