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

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.