KuroKyo
KuroKyo

Reputation: 41

How to print with Angular (4.0)

I've been trying to find a solution to getting an HTML element to print in my MEAN app. I've checked ng-print, angular-print, angular-save-html-to-pdf and more, but these all seem to have been developed for Angularjs. Does anyone have a solution for printing in the newest version of angular?

or failing that, how can I use something like angular-print with angular 2 and above?

for clarification: i'd ideally import the module/directive into app.module.ts, then mark the elements and button i'd like to use with printing in my html file. I also assume i may need to add something to the component linking to the html file. The html would look like:

<button print-directive>Print</button>
<div print-id="printThisElement">
    <p>content</p>
</div>

or

<button (click)="printfunction();">Print</button>
<div print-id="printThisElement">
    <p>content</p>
</div>

Upvotes: 1

Views: 1553

Answers (1)

KuroKyo
KuroKyo

Reputation: 41

Found a NPM package called essence-ng2-print that was compatible with angular and wasn't too much effort to translate. Some parts are not apparent at first but after some digging I was able to get it to work. If anyone ever reads this and finds they have the same problem, but cannot get essence to work, I will post the steps i took here.

Upvotes: 2

Related Questions