docs: clean up providedIn: 'root' syntax for router examples (#20023)

PR Close #20023
This commit is contained in:
Brandon Roberts 2018-09-12 10:12:41 -05:00 committed by Kara Erickson
parent ac5aa8f46d
commit 0aafbac99b
13 changed files with 21 additions and 20 deletions

View File

@ -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(

View File

@ -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) {}

View File

@ -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) {}

View File

@ -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) {}

View File

@ -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) {}

View File

@ -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;

View File

@ -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> {

View File

@ -8,7 +8,7 @@ export interface CanComponentDeactivate {
}
@Injectable({
providedIn: 'root'
providedIn: 'root',
})
export class CanDeactivateGuard implements CanDeactivate<CanComponentDeactivate> {
canDeactivate(component: CanComponentDeactivate) {

View File

@ -2,7 +2,7 @@
import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root'
providedIn: 'root',
})
export class CrisisDetailResolverService {

View File

@ -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;
}
})
);

View File

@ -9,7 +9,7 @@ import { Crisis } from './crisis';
import { CRISES } from './mock-crises';
@Injectable({
providedIn: 'root'
providedIn: 'root',
})
export class CrisisService {
static nextCrisisId = 100;

View File

@ -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 {
/**

View File

@ -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[] = [];