AngularJS Phonecat实例讲解(2)

m1.directive('slide',function(){ return { restrict : 'E', templateUrl : 'template/slide.html', replace : true, scope : { links : '=', w : '@', h : '@' }, link : function(scope,element,attris){ setTimeout(function(){ var w = scope.links.length * scope.w; var h = scope.h; var iNow = 0; $(element).css({'width':scope.w,'height':h,'position':'relative','overflow':'hidden'}) $(element).find('ul').css({'width':w,'height':h,'position':'absolute'}); setTimeout(function(){ $(element).find('li').css({'width':scope.w,'height':h,'float':'left'}); $(element).find('img').css({'width':scope.w,'height':h}); },0); setInterval(function(){ iNow++; $(element).find('ul').animate({'left':-iNow*scope.w},function(){ if(iNow==scope.links.length-1){ $(element).find('ul').css('left',0); iNow = 0; } }); },1000) },50) } } })

结语

AngularJS给我们提供了很多好用的功能,比如路由的管理、数据的过滤的等。更强大的功能还需要进一步的探索,此文仅作为一个好的开端。

您可能感兴趣的文章:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wzzgss.html