Location and HashLocationStrategy stopped working in beta.16

update >= rc.5

@NgModule({
  providers: [{ provide: LocationStrategy, useClass: HashLocationStrategy}]
})
export class AppModule {}

update >= rc.0

import {  
  PlatformLocation,  
  Location,  
  LocationStrategy,  
  HashLocationStrategy,  
  PathLocationStrategy,  
  APP_BASE_HREF}  
from '@angular/common';  

import {BrowserPlatformLocation} from   '@angular/platform-browser';

original

Change

import {ROUTER_PROVIDERS, LocationStrategy, HashLocationStrategy} from 'angular2/router';

to

import {ROUTER_PROVIDERS} from 'angular2/router';
import {LocationStrategy, HashLocationStrategy} from 'angular2/platform/common';

See also
https://github.com/angular/angular/issues/8229

Full list of moved exports:
https://github.com/angular/angular/pull/8230/files

import {  
  PlatformLocation,  
  Location,  
  LocationStrategy,  
  HashLocationStrategy,  
  PathLocationStrategy,  
  APP_BASE_HREF}  
from 'angular2/platform/common';  

import {BrowserPlatformLocation} from   'angular2/src/platform/browser/location/browser_platform_location';

Another error that’s commonly caused by this change is

location.createComponent is not a function

Leave a Comment