2015-06-26 30 views
1
$http({ 
    url: Config.ApiURL + "/site/go", 
    method: "POST", 
    headers: {'Content-Type': 'application/x-www-form-urlencoded'}, 
    data: $.param(testimony) 
}).progress(function (data, status, headers, config) { //Not sure about this line 
    console.log('progressing'); 
}).success(function (data, status, headers, config) { 
    console.log('success'); 
}); 

我想在它成功或錯誤之前顯示一些東西,所以我不知道.progress部分,我只是插入它作爲一個例子,併爲您設想我的問題..是否有可能?有沒有一個內置的功能呢?Http進度函數?

順便說一句,即時通訊新角度。 TIA :)

+0

你需要一個指令。已經有一個SO發佈:http://stackoverflow.com/questions/17144180/angularjs-loading-screen-on-ajax-request – devz

回答

0

據一些文章,我在GitHub上找到(https://github.com/angular/angular.js/issues/1934,請參閱2014年4月26日的帖子),你應該能夠做到這樣的:

$http({method: 'GET', url: '/someUrl',progress:trackProgress}).then(function(result){ 
     // handle result 

});

其中tarckProgress將是一個調用來處理進度狀態的回調函數。

+0

我知道'then'函數的第三個參數是通知回調。這可以掛鉤到XHR進度更新中 –

0

如果你想顯示進度微調/條,並且除了,如果你想別人展示一些東西,你可以用angular-loading-bar