This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Injection Token | |
| const APP_CONFIG = new InjectionToken<AppConfig>('Your description!'); | |
| const appConfig: AppConfig = { ... } | |
| // The provider's configuration. | |
| // At this point, whoever injects APP_CONFIG gets this object. | |
| // But APP_CONFIG is not a class! How do we grab it?... | |
| @NgModule({ | |
| ..., | |
| providers: [{ provide: APP_CONFIG, useValue: appConfig }] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Injectable } from '@angular/core'; | |
| import { | |
| HttpRequest, HttpResponse, | |
| HttpInterceptor, HttpHandler | |
| } from '@angular/common/http'; | |
| import { of } from 'rxjs'; | |
| import { startWith, tap } from 'rxjs/operators'; | |
| @Injectable() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import {HttpContextToken, HttpEvent, HttpHandler, HttpInterceptor, HttpRequest} from '@angular/common/http'; | |
| import {Observable} from 'rxjs'; | |
| import {retry, tap} from 'rxjs/operators'; | |
| export const RETRY_COUNT = new HttpContextToken(() => 3); | |
| export const ERROR_COUNT = new HttpContextToken(() => 0); | |
| export class RetryInterceptor implements HttpInterceptor { | |
| intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Component, ViewChild } from '@angular/core'; | |
| import { | |
| AbstractControl, | |
| FormArray, | |
| FormBuilder, | |
| FormControl, | |
| FormGroup, | |
| FormGroupDirective, NgForm, ValidationErrors, ValidatorFn, | |
| Validators | |
| } from '@angular/forms'; |
OlderNewer