<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="bootstrap.min.css" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >
<script src="jQuery.min.js"></script>
<script src="angular.min.js"></script>
<script src="bootstrap.min.js"></script>
<script type="text/javascript">
var myapp = angular.module('myapp', []);
myapp.controller('myController', function($scope, $q) {
$scope.send = function() {
var deferred = $q.defer();
var promise = deferred.promise;
promise
.then(function() {
console.log('resolve.....')
}, function() {
console.log('reject.....');
}, function() {
console.log('notify.....');
})
.catch(function() {
console.log('catch..error..')
})
.finally(function() {
console.log('anywhere will be called..');
});
deferred.reject('resolve');
};
});
</script>
<style type="text/css">
</style>
</head>
<body ng-app="myapp">
<div ng-controller="myController">
<button class="btn" ng-click="send()">click</button>
</div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="bootstrap.min.css" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >
<script src="jquery.min.js"></script>
<script src="angular.min.js"></script>
<script src="bootstrap.min.js"></script>
<script type="text/javascript">
var myapp = angular.module('myapp', []);
myapp.controller('myController', function($scope, dataService) {
$scope.send = function() {
dataService.getData()
.then(function success(data) {
console.log(data);
}, function error(error) {
console.log(error);
}, function status(process) {
console.log(process);
});
};
});
myapp.factory('dataService', function($q, $interval) {
return {
getData : function() {
var deferred = $q.defer();
var process = 0;
var interval = $interval(function() {
process += 10;
deferred.notify(process);
//reject之后不再继续运行
// if (process == 50) {
// deferred.reject(process);
// }
if (process >= 100) {
$interval.cancel(interval);
deferred.resolve(process);
}
}, 1000);
return deferred.promise;
}
};
});
</script>
<style type="text/css">
</style>
</head>
<body ng-app="myapp">
<div ng-controller="myController">
<button class="btn" ng-click="send()">click</button>
</div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="bootstrap.min.css" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >
<script src="jquery.min.js"></script>
<script src="angular.min.js"></script>
<script src="bootstrap.min.js"></script>
<script type="text/javascript">
var myapp = angular.module('myapp', []);
myapp.controller('myController', function($scope, $q) {
$scope.send = function() {
var deferred = $q.defer();
var promise = deferred.promise;
promise
.then(function() {
console.log('1.....')
})
.then(function() {
console.log('2....');
});
deferred.resolve('resolve');
};
});
</script>
<style type="text/css">
</style>
</head>
<body ng-app="myapp">
<div ng-controller="myController">
<button class="btn" ng-click="send()">click</button>
</div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="bootstrap.min.css" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >
<script src="jquery.min.js"></script>
<script src="angular.min.js"></script>
<script src="bootstrap.min.js"></script>
<script type="text/javascript">
var myapp = angular.module('myapp', []);
myapp.controller('myController', function($scope, $q, $timeout) {
$scope.send = function() {
var deferred = $q.defer();
var promise = deferred.promise;
deferred.resolve('resolve');
promise
.then(function(data) {
console.log(data);
var _deferred = $q.defer();
$timeout(function() {
_deferred.resolve('resolve_');
}, 1000);
return _deferred.promise;
})
.then(function(data) {
console.log(data);
});
};
});
</script>
<style type="text/css">
</style>
</head>
<body ng-app="myapp">
<div ng-controller="myController">
<button class="btn" ng-click="send()">click</button>
</div>
</body>
</html>
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有