How to always run some code when a promise is fulfilled in Angular.js

前端 未结 4 650
囚心锁ツ
囚心锁ツ 2020-12-13 23:17

In my Angular.js application, I\'m running some asynchronous operation. Before it starts I cover the application with a modal div, then once the operation is complete, I nee

4条回答
  •  春和景丽
    2020-12-13 23:26

    I'm using Umbraco version 7.3.5 back end with AngularJS version 1.1.5 and found this thread. When I implemented the approved answer I got the error:

    xxx(...).then(...).finally is not a function

    What did work however was always. If anyone else using an old version of AngularJS finds this thread and can't use finally use this code instead

    LoadingOverlay.start(); 
    Auth.initialize().then(function() {
        // Success handler
    }, function() {
        // Error handler
    }).always(function() {
        // Always execute this on both error and success
    });
    

提交回复
热议问题