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/

  • 相关阅读:
    ng-repeat高级用法
    使用 CSS3 实现超炫的 Loading(加载)动画效果
    ADO.NET访问数据库
    连接查询和分组查询
    T-SQL数据查询基础
    使用SQL语句操作数据
    使用表组织数据
    SQL Sever数据库
    使用属性升级Mybank
    C# 语法
  • 原文地址:https://www.cnblogs.com/ifykwf/p/6043459.html
Copyright © 2011-2022 走看看