在AngularJS相对链接链接、AngularJS

2023-09-14 00:16:59 作者:谎伴

在我的模板,我想使用相对路径。目前,我有我的锚绝对路径的,这是最理想的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?