How to run a onclick javascript function when use Angular ngNoForm

<form target="_blank"id="pdf_form"action="/backend/pdf" ngNoForm method="post" class="pdf-request">


<button type="submit"class="btn btn-info btn-sm mr-2 " (click)="printPdfNow('Yes')"><i class="fa fa-print mr-1 ml-2" aria-hidden="true"></i>Print Now</button>

<input type="hidden"name="print_now"value="No" />


js function in Angular xxx.ts:

    printPdfNow(print_or_not: string) {
        let f = <HTMLFormElement>document.getElementById('pdf_form');
        if (print_or_not == 'Yes') {
            if (confirm('Are your sure to print the harvest slip(s) automatically?')) {
                f.print_now.value = 'Yes';
                return true;
            } else {
                f.print_now.value = 'No';
                return false;
        f.print_now.value = 'No';
        return true;

Leave a Reply

Your email address will not be published. Required fields are marked *