How to ensure completion of an angular.js process

Asked

Viewed 40 times

0

I want to ask for help in this process, I have an application in angular.js that I need to issue all the labels of a process, and then all the labels of a second process.

The problem is that it is occurring to print a process label one after a process label 2 and so on.

This is probably happening because the process executes the second process before the first one is finished.

This way I need to ensure that the first process was finalized before executing the second, some idea?

    enviaImpressao = function (impressor) {

        // Imprime etiquetas de Caixa
        ImprimeEtiquetaService.enviaParaImprsessao ( numeroCaixa, "BOX" ).then(function (result) {

        // Imprime etiquetas de Picking
        ImprimeEtiquetaService.enviaParaImprsessao ( numeroPedido, "PICKING" ).then(function (result) {
    }

Thanks in advance.

  • Enter more details of your code, if possible. With what you have there, I believe that if you chain the execution of "picking", your code will work: Imprimeetiquetaservice.envirParaImprsessao ( numeroCaixa, "BOX" ).then(Function (result) Imprimeetiquetaservice.environmentParaImprsessao ( numeroPedido, "PICKING" ).then(Function (result) {}); });

  • Cezar thanks for the return, it worked but slowed down. Sorry for the ignorance but this process you indicated is similar to a recursive process ?. Thanks in advance.

  • It’s not about recursion but about omissions, you can get more information here: https://answall.com/a/119913/2318

1 answer

1


According to the comment, your problem can be solved as follows:

    enviaImpressao = function (impressor) {

        // Imprime etiquetas de Caixa
        ImprimeEtiquetaService.enviaParaImprsessao ( numeroCaixa, "BOX" ).then(function (result) {
            // Imprime etiquetas de Picking
            ImprimeEtiquetaService.enviaParaImprsessao ( numeroPedido, "PICKING" ).then(function (result) {});

        });      
    }

What happens is that the two calls are chained, that is: first a request will be made by passing the BOX parameter, after the end of it ( which tends to infinity), the next call is executed with the PICKING parameter.

More information can be obtained here:

/a/119913/2318

  • ok. thanks. A hug.

Browser other questions tagged

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