在AngularJS相对链接 [英] Relative links in AngularJS

查看:78
本文介绍了在AngularJS相对链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的模板,我想使用相对路径。目前,我有我的锚绝对路径的,这是最理想的HREF

In my templates I want to use relative routes. Currently I have absolute paths in my anchor href's, which is suboptimal

<a href="/#/dashboard/settings">Settings</a>

我怎么可以重写这是一个相对导航(在这个相对仪表)?

应该与hashbang和HTML5 API历史工作的航线(取AngularJS使用或回落到)

It should work with hashbang and html5 history api routes (whichever AngularJS uses or falls back to)

推荐答案

我不认为你可以重写它使用相对导航。相对是怎么回事,如果你要链接到 /用户/ profile文件来上班,但你的用户是在 /仪表板/设置。如果主导航链接简单地简介(相对),它会去 /仪表板/个人资料,我'M假设是不是你想要的。

I don't think you can rewrite it to use relative navigation. How is relative going to work if you want to link to /user/profile, but your user is on /dashboard/settings. If the main navigation links to simply profile (relative), it's going to go to /dashboard/profile, which I'm assuming is not what you want.

为什么是相对的路径在应用程序中如此重要?高于储蓄按键些什么?

Why is relative pathing so important in your application? Anything more than savings keystrokes?

这篇关于在AngularJS相对链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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