closes #1905 Added section for RouterLinkActive Added section for global query params and fragments Added section for RouterState Added wildcard route to example configuration Updated code samples Renamed .guard files to .service Renamed interfaces.ts to can-deactivate-guard.service.ts Removed unused files
		
			
				
	
	
		
			16 lines
		
	
	
		
			516 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			16 lines
		
	
	
		
			516 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
| // #docregion
 | |
| import { Injectable }    from '@angular/core';
 | |
| import { CanDeactivate } from '@angular/router';
 | |
| import { Observable }    from 'rxjs/Observable';
 | |
| 
 | |
| export interface CanComponentDeactivate {
 | |
|  canDeactivate: () => boolean | Observable<boolean>;
 | |
| }
 | |
| 
 | |
| @Injectable()
 | |
| export class CanDeactivateGuard implements CanDeactivate<CanComponentDeactivate> {
 | |
|   canDeactivate(component: CanComponentDeactivate): Observable<boolean> | boolean {
 | |
|     return component.canDeactivate ? component.canDeactivate() : true;
 | |
|   }
 | |
| }
 |