码迷,mamicode.com
首页 > 其他好文 > 详细

延迟对象$q和供应商配置config

时间:2015-11-22 17:18:03      阅读:148      评论:0      收藏:0      [点我收藏+]

标签:

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();
    
}]);

 

延迟对象$q和供应商配置config

标签:

原文地址:http://www.cnblogs.com/toodeep/p/4986142.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!