Skip to content

Instantly share code, notes, and snippets.

View stevermeister's full-sized avatar
🇺🇦

Stepan Suvorov stevermeister

🇺🇦
View GitHub Profile
@ViewChild('name') nameInput: ElementRef;
ngAfterViewInit() {
console.log(this.nameInput.value)
}
// src/app/auth/auth.service.ts
import { HttpRequest } from '@angular/common/http';
// ...
export class AuthService {
cachedRequests: Array<HttpRequest<any>> = [];
public collectFailedRequest(request): void {
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) {
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';
const myInput = document.getElementById('myInput');
//1 - input
//2 - fetch
//3 - debounce
//Why not Promise?
/*
//---------------------1------------------------
import { Inject, Injectable } from '@angular/core';
import {
BaseRequestOptions,
Headers,
Http,
Request,
RequestOptionsArgs,
Response,
URLSearchParams,
XHRBackend
export function forwardRef(forwardRefFn: ForwardRefFn): Type<any> {
(<any>forwardRefFn).__forward_ref__ = forwardRef;
(<any>forwardRefFn).toString = function() { return stringify(this()); };
return (<Type<any>><any>forwardRefFn);
}
export const My_ACCESSOR = {
provide: NG_VALUE_ACCESSOR,
useExisting: forwardRef(() => MyComponent),
multi: true
};
export class MyComponent {
//...
}
export const MY_ACCESSOR = {
provide: NG_VALUE_ACCESSOR,
useExisting: forwardRef(() => MyComponent),
multi: true
};
@Component({
selector: 'container',
template: '<div appLogClicks></div>'
})
export class Container {}