您好,登錄后才能下訂單哦!
這篇文章將為大家詳細講解有關利用Angular怎么實現一個安裝包下載功能,文章內容質量較高,因此小編分享給大家做個參考,希望大家閱讀完這篇文章后對相關知識有一定的了解。
具體代碼如下所示:
<!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怎么實現一個安裝包下載功能就分享到這里了,希望以上內容可以對大家有一定的幫助,可以學到更多知識。如果覺得文章不錯,可以把它分享出去讓更多的人看到。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。