0
<head>
<script>
function printContent(el){
    var restorepage = document.body.innerHTML;
    var printcontent = document.getElementById(el).innerHTML;
    document.body.innerHTML = printcontent;
    window.print();
    document.body.innerHTML = restorepage;
}
</script>

`

How I can use this script in my component class method.I want when My button is clicked my above script is run but I don't know how manipulation DOM in Angular 2

Dhawal Patel
  • 63
  • 1
  • 9

1 Answers1

1

You do not need to wrap it within a script HTML tag, just call that function (implemented in your TS file) once the button is clicked, something like: <button (click)="printContent()">print</button> . If you're looking for print stuffs, that answer could help you.

Community
  • 1
  • 1
SeleM
  • 9,310
  • 5
  • 32
  • 51