1

Im working on an angular application (Version 6) which is hosted on an AWS s3 Bucket.

There is a little # in my app url routing which wont break my routing or isnt a problem at all. Anyway I tried to get rid of the # with no success so far.

A little Example:

http://localhost:4200/#/Login should be http://localhost:4200/Login

Which is the best way to get rid of the # ?

app-routing.module.ts

import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';

 // ----- Import of all the Components
 ...

export const routes: Routes = [

  { path: '', component: LoginComponent },
  { path: 'Login', component: LoginComponent },
  { path: 'signup', component: signupComponent },
  { path: 'Password', component: PasswordResetComponent, data: {title: 'Passwort Reset'} },
  { path: 'password', component: PasswordResetComponent, data: {title: 'Passwort Reset'} },
  { path: 'confirmation', component: LoginComponent },
  { path: 'Error', component: ErrorPageComponent, data: {title: 'ERROR'} },

export const routing = RouterModule.forRoot(routes);

@NgModule({
   imports: [RouterModule.forRoot(routes)],
   exports: [RouterModule]
})
export class AppRoutingModule { }

In the app.module.ts I just import the AppRoutingModule

sHamann
  • 789
  • 3
  • 10
  • 36
  • @JohanRin You are Right, i will build the app tomorrow to check if its also working on the S3 Bucket. If so, i will mark it as duplicate. – sHamann Jan 17 '19 at 21:59

1 Answers1

2

in your app-routing.module look for this line

RouterModule.forRoot(routes, {useHash : true}) //<= Change this boolean to false

There are currently 2 routing strategies Take a look at this separate related answer to further understand the differences

PathLocationStrategy vs HashLocationStrategy in web apps

Kisinga
  • 1,640
  • 18
  • 27