zoukankan      html  css  js  c++  java
  • angularJS loading 载入画面

    在请求网络的时候,显示loading画面

    1. 使用http的interceptor,截断处理所有的http请求和响应,以及错误。在request的时候设置$rootScope.loading=True,在反馈的时候设置$rootScope.loading=False.

    2. 设置遮罩div,ng-show=loading,即请求中显示遮罩,请求完毕不显示

    细节:

    interceptor

          $httpProvider.interceptors.push(['$q','$rootScope',function($q,$rootScope){
                return {
                    'request': function(config){
                        $rootScope.loading = true;
                        return $q.resolve(config);
                    },
                    'response': function(response){
                        $rootScope.loading = false;
                        return $q.resolve(response);
                    },
                    'requestError':function(rejection){
                        $rootScope.loading = false;
                        return $q.reject(rejection);
                    },
                    'responseError':function(rejection){
                        $rootScope.loading = false;
                        return $q.reject(rejection);
                    }
                }
            }]);

    html

    <div class="flyover" ng-show="loading">
        <div class="mask"></div>
        <div class="alert alert-info">
            <strong>Loading Foo...</strong>
        </div>
    </div>

    css

    /** mask **/
    .flyover .mask {
        top: 0;
        left: 0;
        position: fixed;
        width: 100%;
        height: 100%;
        opacity: 0.5;
        background: black;
        z-index: 1049;
    }
    .flyover .alert{
        left: 50%;
        top: 50%;
        position: fixed;
        z-index: 1050;
    }

    参考:http://tech.wonga.com/angular-http-loader/

  • 相关阅读:
    忠告20岁的年轻人
    mac电脑好用的工具总结
    idea 配置
    mac 安装mysql5.7.28附安装包
    国内外优秀网站收集
    MySql 数据库、数据表操作
    Java 高效代码50例
    Mac 修改版本号
    sql 语句系列(删库跑路系列)[八百章之第七章]
    sql 语句系列(更新系列)[八百章之第六章]
  • 原文地址:https://www.cnblogs.com/ifykwf/p/6043459.html
Copyright © 2011-2022 走看看