Angular实现下载安装包的功能代码分享
更新时间:2017年09月05日 09:19:45 作者:艾斯德斯的博客
本文通过实例代码给大家介绍了angular实现下载安装包的功能以及基于angularjs代码实现锚点跳转的功能,需要的朋友参考下吧
废话不多说了,直接给大家贴代码了,具体代码如下所示:
<!DOCTYPE html> <html ng-app="myPro"> <head> <meta charset="UTF-8"> <title>angular-实现下载安装包的功能</title> <script src="js/angular.min.js"></script> <script src="js/jquery-1.11.0.js"></script> <style> *{padding: 0;margin: 0;} ol,ul{list-style: none;} a{display:block;margin: 200px 0 0 500px;} </style> </head> <body ng-controller="myProController"> <a href="{{onLoadPcUrl}}" rel="external nofollow" >下载安装包</a> </body> <script> var pro = angular.module("myPro",[]); pro.controller("myProController",["$scope","$rootScope","$location",function($scope,$rootScope,$location){ console.log($location.absUrl().split("angularJS")[0]); $scope.onLoadPcUrl = $location.absUrl().split("angularJS")[0]+'angularJS/test/test.zip'; }]); </script> </html>
PS:下面在给大家分享一段代码关于angularJS实现锚点跳转实例
<!DOCTYPE html> <html ng-app = "myPro"> <head> <meta charset="UTF-8"> <title>angularJS_实现锚点跳转实例</title> <script src="js/angular.min.js"></script> <script src="js/jquery-1.11.0.js"></script> <style> *{padding: 0;margin: 0;} ul,ol{list-style: none;} body{background-color: #414246;} ::-webkit-scrollbar{width: 7px;height: 4px;} ::-webkit-scrollbar-track{border-radius:0 ;-webkit-box-shadow: inset 0 0 5px rgba(0,0,0,0.2);background: rgba(0,0,0,0.1);} ::-webkit-scrollbar-thumb{border-radius: 10px;-webkit-box-shadow: inset 0 0 5px rgba(0,0,0,0.2);background: rgba(0,0,0,0.2);} .box{width: 800px;height: 500px;border: 1px solid #000000;margin: 100px auto;background-color: #373a3f;color: #a1a6a7;font-size: 12px;} .box .box-header{width: 790px;height:40px;border: 1px solid #000000;padding: 10px 0 0 10px;font-size: 14px;} .box .box-header ul li{float: left;margin: 0 8px;line-height: 40px;font-size: 16px;cursor: pointer;} .box .box-header ul li.on{color: #0088cc;text-shadow: 0 0 6px #808080;cursor: pointer;} .box .box-main{width: 790px;height: 440px;padding: 10px 0 0 10px;overflow-y:auto;} .box .box-main ul .first_li{width:100%;height: 100px;} .box .box-main ul .first_li .initials{width:100%;height: 20px;line-height: 20px;background-color: #3f4045;} .box .box-main ul .first_li .position{width:100%;} .box .box-main ul .first_li .position ul li{width:50px;height: 20px;line-height: 20px; float: left;text-align: center;margin: 20px;} </style> </head> <body ng-controller = "myProController"> <div class="box"> <div class="box-header"> <ul choice-channel-jump> <li ng-class="{'on':charArray.other}">#</li> <li ng-class="{'on':charArray.A}">A</li> <li ng-class="{'on':charArray.B}">B</li> <li ng-class="{'on':charArray.C}">C</li> <li ng-class="{'on':charArray.D}">D</li> <li ng-class="{'on':charArray.E}">E</li> <li ng-class="{'on':charArray.F}">F</li> <li ng-class="{'on':charArray.G}">G</li> <li ng-class="{'on':charArray.H}">H</li> <li ng-class="{'on':charArray.I}">I</li> <li ng-class="{'on':charArray.J}">J</li> <li ng-class="{'on':charArray.K}">K</li> <li ng-class="{'on':charArray.L}">L</li> <li ng-class="{'on':charArray.M}">M</li> <li ng-class="{'on':charArray.N}">N</li> <li ng-class="{'on':charArray.O}">O</li> <li ng-class="{'on':charArray.P}">P</li> <li ng-class="{'on':charArray.Q}">Q</li> <li ng-class="{'on':charArray.R}">R</li> <li ng-class="{'on':charArray.S}">S</li> <li ng-class="{'on':charArray.T}">T</li> <li ng-class="{'on':charArray.U}">U</li> <li ng-class="{'on':charArray.V}">V</li> <li ng-class="{'on':charArray.W}">W</li> <li ng-class="{'on':charArray.X}">X</li> <li ng-class="{'on':charArray.Y}">Y</li> <li ng-class="{'on':charArray.Z}">Z</li> </ul> </div> <div class="box-main"> <ul> <li class="first_li" ng-repeat="data in positionDatas" id="{{data.letter=='#'?'other':data.letter}}"> <p class="initials">{{data.letter}}</p> <div class="position"> <ul> <li ng-repeat = "d in data.title track by $index"> <p>{{d.name}}</p> </li> </ul> </div> </li> </ul> </div> </div> </body> <script> var pro = angular.module("myPro",[]); pro.controller("myProController",["$scope",function($scope){ var data = [ {"letter":"#","title":[{"name":"张三"},{"name":"李四"},{"name":"周吴"},{"name":"郑王"}]}, {"letter":"A","title":[{"name":"张三"},{"name":"李四"},{"name":"周吴"},{"name":"郑王"}]}, {"letter":"B","title":[{"name":"张三"},{"name":"李四"},{"name":"周吴"},{"name":"郑王"}]}, {"letter":"C","title":[{"name":"张三"},{"name":"李四"},{"name":"周吴"},{"name":"郑王"}]}, {"letter":"D","title":[{"name":"张三"},{"name":"李四"},{"name":"周吴"},{"name":"郑王"}]}, {"letter":"E","title":[{"name":"张三"},{"name":"李四"},{"name":"周吴"},{"name":"郑王"}]}, {"letter":"F","title":[{"name":"张三"},{"name":"李四"},{"name":"周吴"},{"name":"郑王"}]}, {"letter":"G","title":[{"name":"张三"},{"name":"李四"},{"name":"周吴"},{"name":"郑王"}]}, {"letter":"H","title":[{"name":"张三"},{"name":"李四"},{"name":"周吴"},{"name":"郑王"}]}, {"letter":"I","title":[{"name":"张三"},{"name":"李四"},{"name":"周吴"},{"name":"郑王"}]}, {"letter":"J","title":[{"name":"张三"},{"name":"李四"},{"name":"周吴"},{"name":"郑王"}]}, {"letter":"K","title":[{"name":"张三"},{"name":"李四"},{"name":"周吴"},{"name":"郑王"}]}, {"letter":"L","title":[{"name":"张三"},{"name":"李四"},{"name":"周吴"},{"name":"郑王"}]}, {"letter":"M","title":[{"name":"张三"},{"name":"李四"},{"name":"周吴"},{"name":"郑王"}]}, {"letter":"N","title":[{"name":"张三"},{"name":"李四"},{"name":"周吴"},{"name":"郑王"}]}, {"letter":"O","title":[{"name":"张三"},{"name":"李四"},{"name":"周吴"},{"name":"郑王"}]}, {"letter":"P","title":[{"name":"张三"},{"name":"李四"},{"name":"周吴"},{"name":"郑王"}]}, {"letter":"Q","title":[{"name":"张三"},{"name":"李四"},{"name":"周吴"},{"name":"郑王"}]}, {"letter":"R","title":[{"name":"张三"},{"name":"李四"},{"name":"周吴"},{"name":"郑王"}]}, {"letter":"S","title":[{"name":"张三"},{"name":"李四"},{"name":"周吴"},{"name":"郑王"}]}, {"letter":"T","title":[{"name":"张三"},{"name":"李四"},{"name":"周吴"},{"name":"郑王"}]}, {"letter":"U","title":[{"name":"张三"},{"name":"李四"},{"name":"周吴"},{"name":"郑王"}]}, {"letter":"V","title":[{"name":"张三"},{"name":"李四"},{"name":"周吴"},{"name":"郑王"}]}, {"letter":"W","title":[{"name":"张三"},{"name":"李四"},{"name":"周吴"},{"name":"郑王"}]}, {"letter":"X","title":[{"name":"张三"},{"name":"李四"},{"name":"周吴"},{"name":"郑王"}]}, {"letter":"Y","title":[{"name":"张三"},{"name":"李四"},{"name":"周吴"},{"name":"郑王"}]}, {"letter":"Z","title":[{"name":"张三"},{"name":"李四"},{"name":"周吴"},{"name":"郑王"}]} ]; $scope.positionDatas = data; $scope.charArray = { A:false, B:false, C:false, D:false, E:false, F:false, G:false, H:false, I:false, J:false, K:false, L:false, M:false, N:false, O:false, P:false, Q:false, R:false, S:false, T:false, U:false, V:false, W:false, X:false, Y:false, Z:false, other:false }; angular.forEach($scope.positionDatas,function(i){ if(i.letter=="#"){ $scope.charArray.other = true; }else{ $scope.charArray[i.letter] = true; }; }) }]); pro.directive("choiceChannelJump",[function(){ return{ restrict:"A", link:function(scope,element,attr){ var parent = $(".box-main"); var obj = $(element); obj.find("li").click(function(){ var _this = $(this); var text = _this.text(); console.log(text); if(text=="#"){ text = "other"; }; if(_this.hasClass('on')){ parent.animate({scrollTop:$('#'+text).offset().top-parent.offset().top+parent.scrollTop()+'px'}) } }); } } }]); </script> </html>
总结
以上所述是小编给大家介绍的Angular实现下载安装包的功能代码分享,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!
相关文章
AngularJS中如何使用$parse或$eval在运行时对Scope变量赋值
这篇文章主要介绍了AngularJS中如何使用$parse或$eval在运行时对Scope变量赋值的相关资料,本文介绍的非常详细,具有参考借鉴价值,需要的朋友可以参考下2016-01-01BootStrap+Angularjs+NgDialog实现模式对话框
在完成一个后台管理系统时,需要用表格显示注册用户的信息。但是用户地址太长了,不好显示。所以想做一个模式对话框,点击详细地址按钮时,弹出对话框,显示地址。下面小编给大家分享下实现方法,一起看下吧2016-08-08AngularJS通过$location获取及改变当前页面的URL
本篇将介绍AngularJS中的$location服务的基本用法,$location服务的主要作用是用于获取当前url以及改变当前的url,并且存入历史记录。本文通过示例代码介绍的很详细,有需要的朋友们可以参考借鉴,下面来一起看看吧。2016-09-09AngularJS与BootStrap模仿百度分页的示例代码
分页在很多时候都能用到,这篇文章主要介绍了AngularJS与BootStrap模仿百度分页的示例代码,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧2018-05-05Angular中的ActivatedRoute和Router原理解释
这篇文章主要为大家介绍了Angular中的ActivatedRoute和Router原理解释,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步,早日升职加薪2023-04-04
最新评论