31 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			31 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
| // #docregion
 | |
| import { NgModule } from '@angular/core';
 | |
| import { Routes, RouterModule, UrlHandlingStrategy, UrlTree } from '@angular/router';
 | |
| import { APP_BASE_HREF, HashLocationStrategy, LocationStrategy } from '@angular/common';
 | |
| 
 | |
| import { PhoneListComponent }   from './phone-list/phone-list.component';
 | |
| 
 | |
| 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; }
 | |
| }
 | |
| 
 | |
| const routes: Routes = [
 | |
|   { path: '', redirectTo: 'phones', pathMatch: 'full' },
 | |
|   { path: 'phones', component: PhoneListComponent }
 | |
| ];
 | |
| 
 | |
| @NgModule({
 | |
|   imports: [ RouterModule.forRoot(routes) ],
 | |
|   exports: [ RouterModule ],
 | |
|   providers: [
 | |
|     { provide: APP_BASE_HREF, useValue: '!' },
 | |
|     { provide: LocationStrategy, useClass: HashLocationStrategy },
 | |
|     { provide: UrlHandlingStrategy, useClass: Ng1Ng2UrlHandlingStrategy }
 | |
|   ]
 | |
| })
 | |
| export class AppRoutingModule { }
 |