ng-print
v1.0.1
Published
Directive for print content of any HTML element
Downloads
168
Maintainers
Readme
NgPrint
Directive for printing any HTML element. For Angular 2+.
Usage
- Install
npm install ng-print
- Import into main module
import {NgxPrintModule} from 'ng-print';
@NgModule({
imports: [NgPrintModule]
})
export class AppModule {
}
- Add directive to template
<div #printThis>
<!--Element you want to print-->
</div>
<!-- 'printThis' is template reference -->
<button type="button" [elementToPrint]="printThis" ngPrint>Print table</button>
This directive create iframe
on bottom of document and copy all html head into it, so the styles in your angular app are imported into iframe.
Printed element looks pretty much the same as in your app.
Created iframe is set to display:none
.
After print or cancelation, it removes created iframe.
This library was generated with Angular CLI version 8.0.3.