使用同一域中的HREF更改我的角度应用程序的URL

问题描述 投票:0回答:1

是否可以使用href中的html更改URL?如果我单击<a href="http://localhost:4200/products.html>Products</a>文件中的index.html。网址更改1秒钟,然后返回http://localhost:4200/

当我单击链接时,即使src/app/home/home.component.html<a href="http://localhost:4200/products.html>Products</a>仍返回到http://localhost:4200/

我在这个问题上搜索了很多,但所有建议都与路由有关。但是我想通过单击刷新浏览器。如果无法使用href,请给我任何解决此问题的想法。请帮我解决这个问题。先感谢您!

html angularjs angular href
1个回答
0
投票

如果您在$location服务中使用HTML5模式,则可以相对链接到该页面:

<a href="/products.html">Products</a>

这将阻止$location服务重写href。更多:angular docs

© www.soinside.com 2019 - 2024. All rights reserved.