是否可以使用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,请给我任何解决此问题的想法。请帮我解决这个问题。先感谢您!
如果您在$location
服务中使用HTML5模式,则可以相对链接到该页面:
<a href="/products.html">Products</a>
这将阻止$location
服务重写href。更多:angular docs