0

Is there a way that I can get a downloadable HTML file (w/ stylings) from a template reference in Angular? I think I saw there were ways I can get this to be as a PDF and image, but I need the raw HTML.

Right now I have the following:

example-component.html

[...]
<div #previewExample class="preview-wireframe">
    <div class="preview-frame" [ngStyle]="{'width':device === 'mobile' ? '200px' : '500px'}">
        <ng-template [ngTemplateOutlet]="innerTemplate"></ng-template>
        <div class="preview">
            <img [src]="imageToShow"
                class="preview-image"
                alt="Place image title"
                *ngIf="imageToShow && !isImageLoading; else noImageFound">
        </div>
        <ng-template [ngTemplateOutlet]="innerTemplate"></ng-template>
    </div>
</div>
[...]

example-component.ts

@Component({
    selector: 'preview',
    templateUrl: './example-component.html',
    styleUrls: ['./example-component.css'],
})

@ViewChild('previewExample', { static: true }) public previewExample: ElementRef;

downloadRef() {
    // How do I also load this elementRef w/ stylings as well?
    this.previewExample.nativeElement.innerHTML
}
rezey
  • 23
  • 9
  • Does this answer your question? [Is there a way to get the HTML template for an Angular\* component?](https://stackoverflow.com/questions/45497561/is-there-a-way-to-get-the-html-template-for-an-angular-component) – Jacopo Sciampi May 10 '22 at 08:42
  • @JacopoSciampi sadly not... I still need the stylings from styleUrls (./example-component.css) applied from the component. – rezey May 10 '22 at 16:24

0 Answers0