Delay an angular.js $http service

前端 未结 8 1123
感动是毒
感动是毒 2021-01-31 16:32

I have some angular factories for making ajax calls towards legacy ASP.NET .asmx web services like so:

module.factory(\'productService\', [\"$http\",
function ($         


        
8条回答
  •  鱼传尺愫
    2021-01-31 16:47

    If you are using a service that returns a promise, then inside you should put a return before the $timeout as well because that returns just another promise.

    return dataService.loadSavedItem({
        save_id: item.save_id,
        context: item.context
    }).then(function (data) {
        // timeout returns a promise
        return $timeout(function () {
            return data;
        },2000);
    });
    

    Hope it helps someone!

提交回复
热议问题