I started working on angular4 app and I am using hash location strategy
in that app. I am able to introduce hash location strategy
and its working completely fine.
My question is: there is any way to adjust the position of hash
in the url?
For example: My routing module is:
[
{path: '', redirectTo: 'parent', pathMatch: 'full'},
{ path: 'parent',
children: [
{ path: '', redirectTo: 'upload', pathMatch: 'full' },
{ path: 'upload', component: UploaderComponent },
{path: 'dashboard', component: DashboardComponent},
]
}
]
And I am registering these routes as:
RouterModule.forRoot(routes, { useHash: true });
When I loads my app, url comes out as:
http://localhost:4200/#/parent/upload
But, is there any way to make my route as:
http://localhost:4200/parent/#/upload
I was looking into the official doc for angular-routing , but was not able to find out any way to achieve this.
Any useful suggestion to achieve this will be appreciated!!
Thanks!
@ChristianBenseler's comment helped me to get to this solution:
In my Index.html
file, I change the base href as:
<base href="/"> to <base href="/parent">
and in my routing module, it is changed as:
[
{ path: '', redirectTo: 'upload', pathMatch: 'full' },
{ path: 'upload', component: UploaderComponent },
{path: 'dashboard', component: DashboardComponent},
]
This helped to achieve route as:
http://localhost:4200/parent#/upload
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.