If you are new to angular, after hosting your app while on a child route ('www.somewebsite.com/login'), the browser returns with:404 page not found. routing changes happen using simple javascript and work works dynamically. So while you do refresh, angular routing assumes you are on the root route('/').
Angular gave a solution to this using Angular Universal But I prefer using the HashLocatorStrategy
step 1 HashLocationStrategy and LocationStrategy.
In your app.module.ts import the following module HashLocationStrategy and LocationStrategy.
import { HashLocationStrategy, LocationStrategy } from '@angular/common';
add NgModel to provider
providers: [{
{provide: LocationStrategy, useClass: HashLocationStrategy},}]
step 2 import OnSameRouteNavigation:'reload on app.routing.module.ts
In your app.routing.module.ts
import OnSameRouteNavigation:'reload
rebuild your project and host again.
rebuild your project and host again.
@NgModule({
imports: [RouterModule.forRoot(routes, {onSameUrlNavigation: 'reload'})],
exports: [RouterModule]
})
export class AppRoutingModule { }
0 Comments