AngularJS实现的回到顶部指令功能实例

  

本文实例讲述了AngularJS实现的回到顶部指令功能。分享给大家供大家参考,具体如下:

        & lt; !DOCTYPE html>   & lt; html lang=坝τ谩北?   & lt; head>   & lt;元charset=皍tf - 8”比;   & lt;元http-equiv=癤-UA-Compatible”内容=癐E=边缘”比;   & lt;元name=笆哟啊蹦谌?翱矶?设备宽度,初始=1”比;   & lt;链接rel="样式表" href=" https://www.yisu.com/zixun/bootstrap.min.css " rel=巴獠縩ofollow”比;   & lt;脚本src=" https://www.yisu.com/zixun/jquery.min.js "祝辞& lt;/script>   & lt;脚本src=" https://www.yisu.com/zixun/angular.js "祝辞& lt;/script>   & lt;脚本src=" https://www.yisu.com/zixun/bootstrap.min.js "祝辞& lt;/script>   & lt;风格类型=" text/css "比;   # gotoTop {   显示:没有;   位置:固定;   上图:80%;   左:90%;   光标:指针;   填充:4 px 4 px;   宽度:50 px;   边界:1 px固体# e0e0e0;   背景:# fff;   border - radius: 50 px;   高度:50 px;   }   # gotoTop。{徘徊   背景:# e0e0e0;   颜色:# fff;   文字修饰:没有;   }   .arrow {   宽度:0;   高度:0;   保证金:0汽车;   边界:9 px固体透明;   border-bottom-color: # aaa级;   }   .stick {   宽度:8 px;   高度:14 px;   保证金:0汽车;   border - radius: 1 px;   background - color: # aaa级;   }   & lt;/style>   & lt;脚本type=" text/javascript祝辞   var myapp=角。模块(“myapp”, []);   myapp。指令(“goToTop函数(){   返回{   限制:“E”,   替换:没错,   范围:{   minHeight:“@”   },   templateUrl:“tmpl.html”,   链接:函数(范围、elem attrs) {   elem.click(函数(){   jQuery (html、身体)。动画({scrollTop: 0}, 700);   })   .hover(函数(){   jQuery(这).addClass(“悬停”);   },函数(){   jQuery(这).removeClass(“悬停”);   });   范围。minHeight=范围。minHeight & # 63;范围。minHeight: 600;   jQuery(窗口).scroll(函数(){   var s=jQuery(窗口).scrollTop ();   如果(s比;scope.minHeight) {   jQuery (“# gotoTop”) .fadeIn (100);   其他}{   jQuery (“# gotoTop”) .fadeOut (200);   };   });   }   };   });   & lt;/script>   & lt;/head>   & lt;身体ng-app=癿yapp”比;   & lt; go-to-top最小高度=" 800 "祝辞& lt;/go-to-top>   & lt; h2>你好world   & lt; h2>你好world   & lt; h2>你好world   & lt; h2>你好world   & lt; h2>你好world   & lt; h2>你好world   & lt; h2>你好world   & lt; h2>你好world   & lt; h2>你好world   & lt; h2>你好world   & lt; h2>你好world   & lt; h2>你好world   & lt; h2>你好world   & lt; h2>你好world   & lt; h2>你好world   & lt; h2>你好world   & lt; h2>你好world   & lt; h2>你好world   & lt; h2>你好world   & lt; h2>你好world   & lt; h2>你好world   & lt; h2>你好world   & lt; h2>你好world   & lt; h2>你好world   & lt; h2>你好world   & lt; h2>你好world   & lt; h2>你好world   & lt; h2>你好world   & lt; h2>你好world   & lt; h2>你好world   & lt; h2>你好world   & lt; h2>你好world   & lt; h2>你好world   & lt; h2>你好world   & lt; h2>你好world   & lt; h2>你好world   & lt; h2>你好world   & lt; h2>你好world   & lt; h2>你好world   & lt; h2>你好world   & lt; h2>你好world   & lt; h2>你好world   & lt; h2>你好world   & lt; h2>你好world   & lt; h2>你好world   & lt; h2>你好world   & lt; h2>你好world   & lt; h2>你好world   & lt; h2>你好world   & lt; h2>你好world   & lt; h2>你好world   & lt; h2>你好world   & lt; h2>你好world   & lt; h2>你好world   & lt; h2>你好world   & lt; h2>你好world   & lt; h2>你好world   & lt; h2>你好world   & lt; h2>你好world   & lt; h2>你好world   & lt; h2>你好world   & lt; h2>你好world   & lt; h2>你好world   & lt; h2>你好world   & lt; h2>你好world   & lt; h2>你好world   & lt; h2>你好world   & lt; h2>你好world   & lt; h2>你好world   & lt; h2>你好world   & lt; h2>你好world

AngularJS实现的回到顶部指令功能实例