简体   繁体   中英

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.module.ts

在此处输入图片说明

Now, if after this configurations, I think my site should take hash in url like

http://localhost:4200/app#

but it's not working.

can anyone help me with this?

In your app-routing-module.ts use

{ useHash: true}

You already exported RouterModule from app-routing-module.ts so you don't need to agian import in app.module.ts. So remove RouterModule and all related code from app.module.ts and just import app-routing-module.ts in app.module.ts.

Hope it will help.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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