I am developing an application and server which run under Websphere Application Server Liberty profile version 17.0.0.3. I have developed the web application in Angular 4. Everything is working well as long as I don't attempt to refresh/reload a web page. When I try to reload a webpage, I receive a 404 Not Found error. I suspect the problem is that the full url is being passed to the server on refresh. (see Ben Cole's response to this post: What does #/ means in url?)
My problem is that I'm not sure what the best way would be to inject a hashtag into the urls in the application code. I tried simply adding it to the routerLink values in the html, but the url was encoded, converting the hashtag to %23 and then my router didn't recognize the urls.
My Angular 4 application uses Routes and RouterModule from @angular/router. For example, my routes are defined like this:
const routes: Routes = [
{
path: '', component: LayoutComponent,
children: [
{ path: 'dashboard', loadChildren: './dashboard/dashboard.module#DashboardModule' },
{ path: 'versions', loadChildren: './versions/versions.module#VersionsModule' }
]
}
And in my html, I navigate to them in this fashion:
<a [routerLink]="['/versions']"
[routerLinkActive]="['router-link-active']" class="list-group-item">
<i class="fa fa-fw"></i>Versions</a>
My server url is: http://localhost:9080/zss
. When I navigate to my dashboard, the url is: http://localhost:9080/zss/dashboard
But if I try to refresh this webpage, I get the 404 Not Found error.
I think I need to get the Angular application to navigate to urls like: http://localhost:9080/zss/#dashboard
but I'm not sure where to tweak the code to do this or how to overcome the uri encoding which occurs.