javascript - 在angular中$http有没有类似jquery $.ajax()的beforesend的东西
PHP中文网
PHP中文网 2017-04-10 17:58:13
0
1
663

就是想在请求过程的还没请求到的时候加一朵小菊花,现在的代码比如说如下所示,最简单的办法 咋改?

$http.get(url_test).success(function (data) {
                    $('.search-content').hide();
                    $('.search-result').show();
                    $scope.results = data.searchlist;
                });
PHP中文网
PHP中文网

认证高级PHP讲师

reply all(1)
巴扎黑

有,直接见文档 https://docs.angularjs.org/ap...$httpProvider

举个小栗子

var app = angular.module("app", ["$httpProvider", function($httpProvider) {
    // 头部配置
    $httpProvider.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=utf-8';
    $httpProvider.defaults.headers.post['Accept'] = 'application/json, text/javascript, */*; q=0.01';
    $httpProvider.defaults.headers.post['X-Requested-With'] = 'XMLHttpRequest';
}]);

实现http的加载的小菊花,或许题主需要这个
https://github.com/chieffancy...
源代码才300多行

demo预览 https://chieffancypants.githu...

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!