Skip to content

Commit

Permalink
Permit a dynamic title of printing window instead of the old static `…
Browse files Browse the repository at this point in the history
…Print tab`
  • Loading branch information
selemxmn committed Dec 3, 2018
1 parent 8d1b579 commit 2098f3e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
### New features
* Support styles (CSS) ([#5](https://github.com/selemxmn/ngx-print/issues/5))
* Support printing window position by user input ([#4](https://github.com/selemxmn/ngx-print/issues/4))
* Permit a dynamic title of printing window instead of the old static `Print tab`
29 changes: 27 additions & 2 deletions src/lib/ngx-print.directive.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,37 @@
import { Directive, HostListener, Input } from '@angular/core';

/**
*
*
* @export
* @class NgxPrintDirective
*/
@Directive({
selector: 'button[ngxPrint]'
})

export class NgxPrintDirective {

/**
*
*
* @type {string}
* @memberof NgxPrintDirective
*/
@Input() printSectionId: string;

/**
*
*
* @type {string}
* @memberof NgxPrintDirective
*/
@Input() windowTitle: string;

/**
*
*
* @memberof NgxPrintDirective
*/
@HostListener('click', ['$event.target'])
public print(): void {
let printContents, popupWin;
Expand All @@ -16,7 +41,7 @@ export class NgxPrintDirective {
popupWin.document.write(`
<html>
<head>
<title>Print tab</title>
<title>${this.windowTitle ? this.windowTitle : ''}</title>
</head>
<body onload="window.print();window.close()">${printContents}</body>
</html>`
Expand Down

0 comments on commit 2098f3e

Please sign in to comment.