3

I am using the @RouteConfig for navigation and the route config is like

@RouteConfig([
{ path: '/calendar', name: 'Calendar', component: CalendarComponent }]}

The CarouselComponent is loaded when I use route link such as

<a [routerLink]="['Calendar']">Calendar</a>

and the URL routes to http://localhost:60708/calendar

However, when I would like to visit the URL http://localhost:60708/calendar directly by typing the URL in the address bar or to click F5 (Refresh page) after visit the page by clicking the route link, the page does not show any more.

Why does this happen? How can I use the URL path to load the component?

crthompson
  • 15,653
  • 6
  • 58
  • 80
Wenyan
  • 273
  • 4
  • 12
  • Do you get an error message? What location strategy are you using? What HTTP server are you using? – Günter Zöchbauer Jan 12 '16 at 05:53
  • 2
    If your app is front end only you might need to switch to `HashLocationStrategy` see: http://stackoverflow.com/questions/34541532/is-angular-2s-router-broken-when-using-html5-routes and https://angular.io/docs/ts/latest/api/router/HashLocationStrategy-class.html – Langley Jan 12 '16 at 06:55

1 Answers1

1

Thanks for all comments providing the hints.

The main reason is that I did not configure the location strategy at all.

It is working now after I configured the HashLocationStrategy

crthompson
  • 15,653
  • 6
  • 58
  • 80
Wenyan
  • 273
  • 4
  • 12