Reputation: 53
My angular application url shows a #
I don't want to display the #
and I do not know how to delete it.
This is the url of dashboard page - http://localhost:4200/#/dashboard
I want to find a way to make it like - this http://localhost:4200/dashboard
app.routing.module
const routes: Routes = [
{
path: '',
redirectTo: 'dashboard',
pathMatch: 'full',
}, {
path: '',
component: AdminLayoutComponent,
children: [{
path: '',
loadChildren: './layouts/admin-layout/admin-layout.module#AdminLayoutModule'
}]
}
];
@NgModule({
imports: [
CommonModule,
BrowserModule,
RouterModule.forRoot(routes, {
useHash: true
})
],
admin.routing.module
export const AdminLayoutRoutes: Routes =[
{ path: '', component: DashboardComponent },
{ path: 'dashboard', component: DashboardComponent },
{ path: 'connecter', component: ConnecterComponent },
{ path: 'inscrire', component: InscrireComponent },
{ path: 'bibliography', component: BibliographyComponent },
{ path: 'user-profile', canActivate: [AuthGuard], component: UserProfileComponent },
{ path: 'produits', canActivate: [AuthGuard], component: ProduitViewComponent },
{ path: 'produits/view/:id', canActivate: [AuthGuard], component: SingleProduitComponent },
{ path: 'commandes', canActivate: [AuthGuard], component: CommandesViewComponent },
{ path: 'commandes/view/:id', canActivate: [AuthGuard], component: SingleCommandeComponent },
{ path: 'produits/new', canActivate: [AuthGuard], component: ProduitFormComponent },
{ path: 'typography', component: TypographyComponent },
{ path: 'icons', component: IconsComponent },
{ path: 'notifications', component: NotificationsComponent },
{ path: '**', component: NotFoundComponent },
];
@NgModule({
imports: [
CommonModule,
RouterModule.forChild(AdminLayoutRoutes),
]})
Upvotes: 0
Views: 52
Reputation: 9230
In your router module you have the following
RouterModule.forRoot(routes, {
useHash: true
})
remove useHash: true
so it should now look like this
RouterModule.forRoot(routes)
Upvotes: 1