ajax加载动画指令
来源:互联网 发布:java教程入门视频 编辑:程序博客网 时间:2024/05/17 08:35
//html部分
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<meta content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport">
<meta http-equiv="Cache-Control" content="no-cache">
<title>ajaxLoading</title>
</head>
<style>
</style>
<body ng-app="myApp" ng-controller="MyController">
<loading></loading>
<script src="./js/jquery.js"></script>
<script src="./js/angular.js"></script>
<script src="./js/service.js"></script>
<script src="./js/app.js"></script>
<script src="./js/controller.js"></script>
</body>
</html>
//app.js需要依赖ajaxLoading模块
var app = angular.module('myApp',['ajaxLoading']);
//功能代码
/**
* 拦截器 全局$http注入loading效果
*/
angular.module('ajaxLoading', [])
.config(function($httpProvider) {
$httpProvider.interceptors.push('loadingInterceptor');
})
.directive('loading', function() {
return {
replace: true,
restrict: 'AE',
template:'<div class="back-layer"><div class="loading">'
+'<img src="js/729.GIF">'
+'</div></div>',
link: function($scope, $element, attrs) {
var top = $(window).height()/2 - 25;
var left = $(window).width()/2 - 25;
$('.loading img').css({
height:'50px',
width:'50px'
})
$('.loading').css({
position:'fixed',
top: top,
left: left
});
}
};
})
.factory('loadingInterceptor', function($q, $rootScope) {
return {
request: function(config) {
$(".back-layer").show();
return config || $q.when(config);
},
response: function(response) {
$(".back-layer").hide();
return response || $q.when(response);
},
responseError: function(rejection) {
$(".back-layer").hide();
return $q.reject(rejection);
}
};
});
//一个ajax请求用作测试
app.controller('MyController',['$scope','$http',function($scope,$http){
$http({
method:'JSONP',
url:'https://api.github.com/user/'+1+'/'+'events'+'?callback=JSON_CALLBACK'
}).success(function(data){
console.log(data);
})
}])
云盘
http://pan.baidu.com/s/1cDkE7s
- ajax加载动画指令
- ajax加载数据动画
- ajax加载动画实现jquery加载动画
- 使用CSS3构建Ajax加载动画
- 使用CSS3构建Ajax加载动画
- 使用CSS3构建Ajax加载动画
- ajax 加载数据前显示动画
- Ajax同步调用影响加载动画展示
- jquery ajax 加载数据的时候异步显示加载动画
- jquery ajax 加载数据的时候异步显示加载动画
- jQuery Ajax 加载数据时异步显示加载动画
- jquery Ajax 实现加载数据前动画效果
- AngularJs 自定义ajax服务为请求添加加载动画
- 通过$.ajax设置预加载动画加强用户体验
- 通过$.ajax设置预加载动画加强用户体验
- JQuery、AJAX加载数据时候的loading加载动画实现步骤
- 加载动画
- 加载动画
- iOS 组件化方案探索
- WPF开篇
- GoogleMaps踏坑之旅(三)
- oracle外键属性
- 如何检查软键盘是否可见
- ajax加载动画指令
- 第3章 栈、队列和数组
- Linux管理员不得不知道的知识点
- 围观神仙打架,反革命工程师《iOS应用架构谈 组件化方案》和蘑菇街Limboy的《蘑菇街 App 的组件化之路》的阅读指导
- css3写导入跳动的音乐
- 深入理解 HTTP 协议 POST 与PUT 方法区别
- WPF Step By Step -基础知识介绍
- java 电话号码归属地查询
- 从ArrayList看Java泛型