Good day, everyone.
From the modal component that will input some data I need open new browser tab with resulted HTML that will contain formatted input data, example of code (i simplify it and try to use ng-template instead of one more component that should include resulted html):
@Component({
template:
'<p class="error" (click)="this.openValidationWarningsInNewWindow(hello)">Validation Warnings - click to see details</p>\n' +
'\n' +
'<ng-template #hello>\n' +
' <div>formatedData: someData.value</div>\n' +
'</ng-template>\n'
})
export class ValidationMessageComponent {
@Input() someData: DataModel;
@ViewChild('hello') helloEl: ElementRef;
private openValidationWarningsInNewWindow(content: any) {
const newWindow = window.open('about:blank', '_blank');
let hell = this.helloEl.nativeElement as HTMLElement;
newWindow.document.write(hell.innerText);
newWindow.document.title = 'Validation Warnings';
newWindow.document.close();
}
}
Sure, the way described in example doesn't work, at least I'm not able to get interHTML of nativeElement. In new tab, i need just html representation (it's could be just simple HTML, but in this tab this html should included binded data) Although, the way with [routerLink] and '_blank' target doesn't work, cause I need to transfer binding data.
Do you have any ideas?