angular跳转到html5,在AngularJS中如何实现跳转功能

这篇文章主要介绍了AngularJS实现的锚点楼层跳转功能,涉及AngularJS事件响应实现锚点跳转功能的相关操作技巧,需要的朋友可以参考下

本文实例讲述了AngularJS实现的锚点楼层跳转功能。分享给大家供大家参考,具体如下:

anchor

#wei p{

width:100%;

height:720px;

background: red;

color:#fff;

text-align:center;

line-height: 720px;

margin:20px;

font-size: 80px;

}

#wei ul{

position: fixed;

top:300px;

right:60px;

}

#wei ul li{

width:20px;

display:block;

height:20px;

background: gray;

color:#fff;

text-align:center;

line-height: 20px;

border-radius: 50%;

margin-bottom: 20px;

cursor: pointer;

}

{{attr}}

  • {{attr}}

var app = angular.module('myApp',[]);

app.controller('show',['$scope','$location','$anchorScroll',function($scope,$location,$anchorScroll){

$scope.arr=[1,2,3,4,5];

$scope.jump=function(id){

//console.log(id);

$location.hash(id);//添加锚点

$anchorScroll(); //重新定义服务,解决当滑动时点击锚点无作用的bug

}

}]);

运行效果如下:

点击锚点2:

765ee8fa4382f982bb2e0ea6d0fede0e.png

点击锚点3:

1fec86e09b0a0abd5dd8166aab388411.png

上面是我整理给大家的,希望今后会对大家有帮助。

相关文章:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值