I am currently tackling a project in Angular2 using TypeScript, and I seem to be having trouble with the HashLocationStrategy. Despite following the instructions on how to override the LocationStrategy as laid out here, I can't seem to get it to work properly.
import {bootstrap} from 'angular2/platform/browser';
import {ROUTER_PROVIDERS} from 'angular2/router';
import {AppComponent} from './app.component';
// Utilize these symbols for overriding the `LocationStrategy`
import {provide} from 'angular2/core';
import {LocationStrategy,
HashLocationStrategy} from 'angular2/router';
bootstrap(AppComponent, [
ROUTER_PROVIDERS,
provide(LocationStrategy,
{useClass: HashLocationStrategy})
]);
I've put together a plunker showcasing the issue here: https://plnkr.co/edit/YE5w4iky53SHRi211lqX?p=preview
Is anyone else facing the same problem? Do you think I've misinterpreted something or overlooked a crucial detail?
Edit: The desired outcome is for the routing to incorporate hashes in the URL. For example, instead of .../fubar, it should display .../#/fubar in the URL as demonstrated in the example.
To view the resulting URLs, it's recommended to open the plunker in a separate window (click on the blue full-screen button).