
1.angular总的$q和jquery中的延迟对象很类似,用法也差不多
m1.controller('meng',['$scope','$q',function($scope,$q){ var dfd = $q.defer();
function show(){
setTimeout(function(){
dfd.reject();
},2000);
return dfd.promise;
}
show().then(function(){
alert('成功');
},function(){
alert('失败');
}); }]);
2.服务r的config配置
angular的服务如$interpolate,$anchorScroll都可以惊行一些初始配置:
m1.config(['$anchorScrollProvider',function($anchorScrollProvider){ $anchorScrollProvider.disableAutoScrolling(); }]);