简体   繁体   English

路由的角度4哈希URL问题

[英]angular 4 hash url issue with routing

I am not getting hash in my angular app for local site. 我在本地站点的我的角度应用程序中没有得到哈希。

my configurations are here. 我的配置在这里。

app-routing-module.ts app-routing-module.ts

在此处输入图片说明

app.module.ts app.module.ts

在此处输入图片说明

Now, if after this configurations, I think my site should take hash in url like 现在,如果经过此配置,我认为我的网站应采用url中的哈希值,例如

http://localhost:4200/app# http:// localhost:4200 / app#

but it's not working. 但它不起作用。

can anyone help me with this? 谁能帮我这个?

In your app-routing-module.ts use 在您的app-routing-module.ts中使用

{ useHash: true}

You already exported RouterModule from app-routing-module.ts so you don't need to agian import in app.module.ts. 您已经从app-routing-module.ts中导出了RouterModule,因此无需在app.module.ts中进行agian导入。 So remove RouterModule and all related code from app.module.ts and just import app-routing-module.ts in app.module.ts. 因此,从app.module.ts中删除RouterModule和所有相关代码,然后在app.module.ts中导入app-routing-module.ts。

Hope it will help. 希望它会有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM