diff --git a/src/lib/ngx-print.directive.ts b/src/lib/ngx-print.directive.ts index dde9f26..c6a12fa 100644 --- a/src/lib/ngx-print.directive.ts +++ b/src/lib/ngx-print.directive.ts @@ -1,20 +1,15 @@ import { Directive, HostListener, Input } from '@angular/core'; -/** - * - * - * @export - * @class NgxPrintDirective - */ @Directive({ selector: 'button[ngxPrint]' }) export class NgxPrintDirective { + private _printStyle = []; + /** * * - * @type {string} * @memberof NgxPrintDirective */ @Input() printSectionId: string; @@ -22,10 +17,34 @@ export class NgxPrintDirective { /** * * - * @type {string} * @memberof NgxPrintDirective */ - @Input() windowTitle: string; + @Input() printTitle: string; + + /** + * + * + * @memberof NgxPrintDirective + */ + @Input() + set printStyle(values: {[key: string]: {[key: string]: string}}) { + for (var key in values) { + if (values.hasOwnProperty(key)) { + this._printStyle.push((key + JSON.stringify(values[key])).replace(/['"]+/g, '')); + } + } + this.returnStyleValues(); + } + +/** + * + * + * @returns + * @memberof NgxPrintDirective + */ +private returnStyleValues() { + return this._printStyle.join(' '); + } /** * @@ -41,7 +60,10 @@ export class NgxPrintDirective { popupWin.document.write(` - ${this.windowTitle ? this.windowTitle : ''} + ${this.printTitle ? this.printTitle : ''} + ${printContents} `