Moved all heroes functionality into milestone 2 Crisis Center initial functionality is milestone 3 Admin feature module as milestone 4 including route guard examples Updated milestone 5 to lazy load admin feature module Added examples for CanLoad, CanActivateChildren guard, component-less routes Added section on explanation of ActivatedRoute Added section on animating route components Added section on relative navigation
		
			
				
	
	
		
			16 lines
		
	
	
		
			504 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			16 lines
		
	
	
		
			504 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
| // #docregion
 | |
| import { Injectable }    from '@angular/core';
 | |
| import { CanDeactivate } from '@angular/router';
 | |
| import { Observable }    from 'rxjs/Observable';
 | |
| 
 | |
| export interface CanComponentDeactivate {
 | |
|  canDeactivate: () => Observable<boolean> | Promise<boolean> | boolean;
 | |
| }
 | |
| 
 | |
| @Injectable()
 | |
| export class CanDeactivateGuard implements CanDeactivate<CanComponentDeactivate> {
 | |
|   canDeactivate(component: CanComponentDeactivate) {
 | |
|     return component.canDeactivate ? component.canDeactivate() : true;
 | |
|   }
 | |
| }
 |