This file contains 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
@ViewChild('name') nameInput: ElementRef; | |
ngAfterViewInit() { | |
console.log(this.nameInput.value) | |
} |
This file contains 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
// src/app/auth/auth.service.ts | |
import { HttpRequest } from '@angular/common/http'; | |
// ... | |
export class AuthService { | |
cachedRequests: Array<HttpRequest<any>> = []; | |
public collectFailedRequest(request): void { |
This file contains 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 'rxjs/add/operator/map'; | |
export class JwtInterceptor implements HttpInterceptor { | |
constructor(public auth: AuthService) {} | |
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> { | |
return next.handle(req).map((event: HttpEvent<any>) => { | |
if (event instanceof HttpResponse) { |
This file contains 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, | |
HttpHandler, | |
HttpEvent, | |
HttpInterceptor | |
} from '@angular/common/http'; | |
import { AuthService } from './auth/auth.service'; | |
import { Observable } from 'rxjs/Observable'; |
This file contains 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
const myInput = document.getElementById('myInput'); | |
//1 - input | |
//2 - fetch | |
//3 - debounce | |
//Why not Promise? | |
/* | |
//---------------------1------------------------ |
This file contains 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 { Inject, Injectable } from '@angular/core'; | |
import { | |
BaseRequestOptions, | |
Headers, | |
Http, | |
Request, | |
RequestOptionsArgs, | |
Response, | |
URLSearchParams, | |
XHRBackend |
This file contains 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
export function forwardRef(forwardRefFn: ForwardRefFn): Type<any> { | |
(<any>forwardRefFn).__forward_ref__ = forwardRef; | |
(<any>forwardRefFn).toString = function() { return stringify(this()); }; | |
return (<Type<any>><any>forwardRefFn); | |
} |
This file contains 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
export const My_ACCESSOR = { | |
provide: NG_VALUE_ACCESSOR, | |
useExisting: forwardRef(() => MyComponent), | |
multi: true | |
}; | |
export class MyComponent { | |
//... | |
} |
This file contains 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
export const MY_ACCESSOR = { | |
provide: NG_VALUE_ACCESSOR, | |
useExisting: forwardRef(() => MyComponent), | |
multi: true | |
}; |
This file contains 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
@Component({ | |
selector: 'container', | |
template: '<div appLogClicks></div>' | |
}) | |
export class Container {} |