亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

AngularJS模塊學(xué)習(xí)之Anchor Scroll

 更新時間:2016年01月19日 14:20:42   作者:林松2012  
這篇文章主要介紹了AngularJS模塊學(xué)習(xí)之Anchor Scroll 的相關(guān)資料,需要的朋友可以參考下

俗話說的好:好記性不如一個爛筆頭,本文對angularjs模塊學(xué)習(xí)筆記,首先我們從anchor scroll開始學(xué)習(xí),具體內(nèi)容請看下文:

•$anchorScroll()用于跳轉(zhuǎn)至定義ID;
•$location對象的hash()方法會替換當(dāng)前url作為hash鍵;
•$anchorScroll()讀取并跳轉(zhuǎn)至ID處。

下面簡單的例子,這里是輸出結(jié)果:

源碼 index.html--11行,標(biāo)示了的跳轉(zhuǎn)ID:

<!DOCTYPE html>
<html ng-app="app">
<head>
<script src="angular.min.js"></script>
<script src="app.js"></script>
<meta charset="utf-">
</head>
<body ng-controller="MockController">
<button ng-repeat="(key, value) in numbers" ng-click="jumper(key)"> {{key}} </button>
<div ng-repeat="(key, value) in numbers" id="{{key}}">
<h>{{key}}</h>
<ol>
<ul ng-repeat="item in value"> {{item}} </ul>
</ol>
</div>
</body>
</html>

app.js

var demoApp = angular.module("app",[])
.controller("MockController",
function ($scope, $location, $anchorScroll) {
$scope.numbers = {
"自然數(shù)":["","","","","","","","","","","","","","","","","","","",""],
"質(zhì)數(shù)":["","","","","","", "", "", "", ""]
};
$scope.jumper = function(key){
$location.hash(key);
$anchorScroll();
}
});

以上所述是小編給大家整理的AngularJS模塊學(xué)習(xí)之Anchor Scroll 的相關(guān)內(nèi)容,希望大家喜歡。

相關(guān)文章

最新評論