你如何链接到角网页的特定部分? [英] How do you link to a specific part of the page in Angular?

查看:75
本文介绍了你如何链接到角网页的特定部分?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要做出一个典型的返回顶部的链接通常你会放,说

To make a typical "Go back to top" link usually you would put, say

<a id="top"></a>
[...]
<a href="#top">Top</a>

在AngularJS这个链接试图去而不是example.com/#top~~V,因此它可以追溯到缺省路由。你怎么这个环节适当地告诉角度看待?

In AngularJS this link tries to go to example.com/#top instead, therefore it goes back to the default route. How do you tell angular treat this link appropriately?

推荐答案

您将使用$ anchorScroll服务。

You would use the $anchorScroll service.

http://docs.angularjs.org/api/ng.$anchorScroll

这篇关于你如何链接到角网页的特定部分?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆