docs: clean up providedIn: 'root' syntax for router examples (#20023)
PR Close #20023
This commit is contained in:
		
							parent
							
								
									ac5aa8f46d
								
							
						
					
					
						commit
						0aafbac99b
					
				| @ -1,10 +1,9 @@ | ||||
| // #docregion
 | ||||
| import { Injectable } from '@angular/core'; | ||||
| import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router'; | ||||
| import { Observable } from 'rxjs/Observable'; | ||||
| 
 | ||||
| @Injectable({ | ||||
|   providedIn: 'root' | ||||
|   providedIn: 'root', | ||||
| }) | ||||
| export class AuthGuard implements CanActivate { | ||||
|   canActivate( | ||||
|  | ||||
| @ -1,12 +1,11 @@ | ||||
| // #docregion
 | ||||
| import { Injectable } from '@angular/core'; | ||||
| import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, Router } from '@angular/router'; | ||||
| import { Observable } from 'rxjs/Observable'; | ||||
| 
 | ||||
| import { AuthService }      from './auth.service'; | ||||
| 
 | ||||
| @Injectable({ | ||||
|   providedIn: 'root' | ||||
|   providedIn: 'root', | ||||
| }) | ||||
| export class AuthGuard implements CanActivate { | ||||
|   constructor(private authService: AuthService, private router: Router) {} | ||||
|  | ||||
| @ -9,7 +9,7 @@ import { | ||||
| import { AuthService }      from './auth.service'; | ||||
| 
 | ||||
| @Injectable({ | ||||
|   providedIn: 'root' | ||||
|   providedIn: 'root', | ||||
| }) | ||||
| export class AuthGuard implements CanActivate, CanActivateChild { | ||||
|   constructor(private authService: AuthService, private router: Router) {} | ||||
|  | ||||
| @ -11,7 +11,7 @@ import { | ||||
| import { AuthService }      from './auth.service'; | ||||
| 
 | ||||
| @Injectable({ | ||||
|   providedIn: 'root' | ||||
|   providedIn: 'root', | ||||
| }) | ||||
| export class AuthGuard implements CanActivate, CanActivateChild { | ||||
|   constructor(private authService: AuthService, private router: Router) {} | ||||
|  | ||||
| @ -11,7 +11,7 @@ import { | ||||
| import { AuthService }      from './auth.service'; | ||||
| 
 | ||||
| @Injectable({ | ||||
|   providedIn: 'root' | ||||
|   providedIn: 'root', | ||||
| }) | ||||
| export class AuthGuard implements CanActivate, CanActivateChild, CanLoad { | ||||
|   constructor(private authService: AuthService, private router: Router) {} | ||||
|  | ||||
| @ -5,7 +5,7 @@ import { Observable, of } from 'rxjs'; | ||||
| import { tap, delay } from 'rxjs/operators'; | ||||
| 
 | ||||
| @Injectable({ | ||||
|   providedIn: 'root' | ||||
|   providedIn: 'root', | ||||
| }) | ||||
| export class AuthService { | ||||
|   isLoggedIn = false; | ||||
|  | ||||
| @ -8,7 +8,7 @@ import { CanDeactivate, | ||||
| import { CrisisDetailComponent } from './crisis-center/crisis-detail/crisis-detail.component'; | ||||
| 
 | ||||
| @Injectable({ | ||||
|   providedIn: 'root' | ||||
|   providedIn: 'root', | ||||
| }) | ||||
| export class CanDeactivateGuard implements CanDeactivate<CrisisDetailComponent> { | ||||
| 
 | ||||
|  | ||||
| @ -8,7 +8,7 @@ export interface CanComponentDeactivate { | ||||
| } | ||||
| 
 | ||||
| @Injectable({ | ||||
|   providedIn: 'root' | ||||
|   providedIn: 'root', | ||||
| }) | ||||
| export class CanDeactivateGuard implements CanDeactivate<CanComponentDeactivate> { | ||||
|   canDeactivate(component: CanComponentDeactivate) { | ||||
|  | ||||
| @ -2,7 +2,7 @@ | ||||
| import { Injectable } from '@angular/core'; | ||||
| 
 | ||||
| @Injectable({ | ||||
|   providedIn: 'root' | ||||
|   providedIn: 'root', | ||||
| }) | ||||
| export class CrisisDetailResolverService { | ||||
| 
 | ||||
|  | ||||
| @ -1,16 +1,19 @@ | ||||
| 
 | ||||
| // #docregion
 | ||||
| import { Injectable }             from '@angular/core'; | ||||
| import { Router, Resolve, RouterStateSnapshot, | ||||
|          ActivatedRouteSnapshot } from '@angular/router'; | ||||
| import { Observable, of, EMPTY as empty }             from 'rxjs'; | ||||
| import { | ||||
|   Router, Resolve, | ||||
|   RouterStateSnapshot, | ||||
|   ActivatedRouteSnapshot | ||||
| }                                 from '@angular/router'; | ||||
| import { Observable, of, EMPTY }  from 'rxjs'; | ||||
| import { mergeMap, take }         from 'rxjs/operators'; | ||||
| 
 | ||||
| import { CrisisService }  from './crisis.service'; | ||||
| import { Crisis } from './crisis'; | ||||
| 
 | ||||
| @Injectable({ | ||||
|   providedIn: 'root' | ||||
|   providedIn: 'root', | ||||
| }) | ||||
| export class CrisisDetailResolverService implements Resolve<Crisis> { | ||||
|   constructor(private cs: CrisisService, private router: Router) {} | ||||
| @ -25,7 +28,7 @@ export class CrisisDetailResolverService implements Resolve<Crisis> { | ||||
|           return of(crisis); | ||||
|         } else { // id not found
 | ||||
|           this.router.navigate(['/crisis-center']); | ||||
|           return empty; | ||||
|           return EMPTY; | ||||
|         } | ||||
|       }) | ||||
|     ); | ||||
|  | ||||
| @ -9,7 +9,7 @@ import { Crisis } from './crisis'; | ||||
| import { CRISES } from './mock-crises'; | ||||
| 
 | ||||
| @Injectable({ | ||||
|   providedIn: 'root' | ||||
|   providedIn: 'root', | ||||
| }) | ||||
| export class CrisisService { | ||||
|   static nextCrisisId = 100; | ||||
|  | ||||
| @ -8,7 +8,7 @@ import { Observable, of } from 'rxjs'; | ||||
|  * TODO: better modal implementation that doesn't use window.confirm | ||||
|  */ | ||||
| @Injectable({ | ||||
|   providedIn: 'root' | ||||
|   providedIn: 'root', | ||||
| }) | ||||
| export class DialogService { | ||||
|   /** | ||||
|  | ||||
| @ -4,7 +4,7 @@ import { PreloadingStrategy, Route } from '@angular/router'; | ||||
| import { Observable, of } from 'rxjs'; | ||||
| 
 | ||||
| @Injectable({ | ||||
|   providedIn: 'root' | ||||
|   providedIn: 'root', | ||||
| }) | ||||
| export class SelectivePreloadingStrategyService implements PreloadingStrategy { | ||||
|   preloadedModules: string[] = []; | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user