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
		
			
				
	
	
		
			24 lines
		
	
	
		
			499 B
		
	
	
	
		
			TypeScript
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			24 lines
		
	
	
		
			499 B
		
	
	
	
		
			TypeScript
		
	
	
		
			Executable File
		
	
	
	
	
| // #docregion
 | |
| import { Injectable } from '@angular/core';
 | |
| 
 | |
| import { Observable } from 'rxjs/Observable';
 | |
| import 'rxjs/add/observable/of';
 | |
| import 'rxjs/add/operator/do';
 | |
| import 'rxjs/add/operator/delay';
 | |
| 
 | |
| @Injectable()
 | |
| export class AuthService {
 | |
|   isLoggedIn: boolean = false;
 | |
| 
 | |
|   // store the URL so we can redirect after logging in
 | |
|   redirectUrl: string;
 | |
| 
 | |
|   login() {
 | |
|     return Observable.of(true).delay(1000).do(val => this.isLoggedIn = true);
 | |
|   }
 | |
| 
 | |
|   logout() {
 | |
|     this.isLoggedIn = false;
 | |
|   }
 | |
| }
 |