How to call ng-Blur query function before printing from PDF in Angularjs

Asked

Viewed 110 times

0

I have a field CPF (text) where I consult a function consultaNome for return the NAME of CPF and I have the button 'Generate PDF' where I need to print out the CPF and NAME that was returned.

I’m using the bg-Blur to carry out the consultation after leaving the setfocus of the text.

CPF FIELD IN FORM

<div class="form-group" data-ng-if="vm.tipoPessoa === 'PF'">
    <label for="cpf">CPF:</label>
    <input type="text" ng-blur="vm.carregarNomeSicli()" id="cpf" name="cpf" data-ng-model="vm.cpfcnpj" class="form-control input-sm" />
    <div data-ng-if="!vm.isValidoValor()">
        <em style="color: red;" class="glyphicon glyphicon-remove"></em>
        <span style="color: red;">{{vm.messageService.getN('MN019')}}</span>
    </div>
</div>

GENERATE PDF BUTTON

<div class="pull-right">
    <button id="imprime" type="button" data-ng-click="PDF()" class="btn btn-sm btn-primary">
        <i class="glyphicon glyphicon-save-file"></i> <span>Gerar PDF</span>
    </button>
</div>

THE PROBLEM:

When altero the CPF without leaving the setfocus and right-click the button 'Generate PDF' is triggering the print before returning the NAME of the new CPF.

I’m looking for a solution where I can activate before the query only to print... Some team or refactoring of the process to print always after the execution of the query.

function imprimePDF() {
   $scope.PDF = function() {};
}

1 answer

0

Before executing the code that prints the PDF, you can call the method to load Myfolder(). This way, it will execute the method to load NomeSicli(), then print PDF functionality

Browser other questions tagged

You are not signed in. Login or sign up in order to post.