2016-09-27 04:22:38 -04:00
|
|
|
// #docregion
|
|
|
|
import { NgModule } from '@angular/core';
|
2017-02-13 11:45:37 -05:00
|
|
|
import { Routes, RouterModule, UrlHandlingStrategy, UrlTree } from '@angular/router';
|
2016-09-27 04:22:38 -04:00
|
|
|
import { APP_BASE_HREF, HashLocationStrategy, LocationStrategy } from '@angular/common';
|
|
|
|
|
|
|
|
import { PhoneListComponent } from './phone-list/phone-list.component';
|
|
|
|
|
2017-02-13 11:45:37 -05:00
|
|
|
export class Ng1Ng2UrlHandlingStrategy implements UrlHandlingStrategy {
|
|
|
|
shouldProcessUrl(url: UrlTree) {
|
|
|
|
return url.toString() === '/' || url.toString() === '/phones';
|
|
|
|
}
|
|
|
|
extract(url: UrlTree) { return url; }
|
|
|
|
merge(url: UrlTree, whole: UrlTree) { return url; }
|
|
|
|
}
|
|
|
|
|
2016-09-27 04:22:38 -04:00
|
|
|
const routes: Routes = [
|
|
|
|
{ path: '', redirectTo: 'phones', pathMatch: 'full' },
|
2017-02-13 11:45:37 -05:00
|
|
|
{ path: 'phones', component: PhoneListComponent }
|
2016-09-27 04:22:38 -04:00
|
|
|
];
|
|
|
|
|
|
|
|
@NgModule({
|
|
|
|
imports: [ RouterModule.forRoot(routes) ],
|
|
|
|
exports: [ RouterModule ],
|
|
|
|
providers: [
|
|
|
|
{ provide: APP_BASE_HREF, useValue: '!' },
|
|
|
|
{ provide: LocationStrategy, useClass: HashLocationStrategy },
|
2017-02-13 11:45:37 -05:00
|
|
|
{ provide: UrlHandlingStrategy, useClass: Ng1Ng2UrlHandlingStrategy }
|
2016-09-27 04:22:38 -04:00
|
|
|
]
|
|
|
|
})
|
2017-02-13 11:45:37 -05:00
|
|
|
export class AppRoutingModule { }
|