3

Moving from ng1 to ng2, I would like to continue using anchor hash '#' for routing.

afaik, ng2 uses default PathLocationStrategy wherein we define a <base-href="/"> which is the base path used by angular 2 router for client side routing, documented here.

Since I am using HashLocationStrategy, will there be any problems if I remove <base-href=""> from index.html? I have created a small app with following routes and it seems to be working fine.

 export const ROUTES: Routes = [{
   path: '', redirectTo: 'login', pathMatch: 'full'
  }, {
    path: 'app',  component: AppComponent
  }, {
    path: 'login', component: LoginComponent
  }, {
    path: 'error', component: ErrorComponent
  }
];

thanks,

kboul
  • 13,836
  • 5
  • 42
  • 53
Ric K
  • 648
  • 1
  • 6
  • 16

1 Answers1

0

If you are using useHash: true with the Approute then no need to provide base-href as it is redundant as both helps in refresh of page,but follow different concept.