Skip to content

Instantly share code, notes, and snippets.

View stevermeister's full-sized avatar
🇺🇦

Stepan Suvorov stevermeister

🇺🇦
View GitHub Profile
@stevermeister
stevermeister / bazel-start.sh
Last active October 5, 2018 09:12
Run to setup bazel files for fresh ng-cli project
yarn global add @bazel/ibazel
curl https://raw.githubusercontent.com/alexeagle/canonical-angularcli-app/master/.bazelrc > .bazelrc
curl https://raw.githubusercontent.com/alexeagle/canonical-angularcli-app/master/WORKSPACE > WORKSPACE
curl https://raw.githubusercontent.com/alexeagle/canonical-angularcli-app/master/BUILD.bazel > BUILD.bazel
curl https://raw.githubusercontent.com/alexeagle/canonical-angularcli-app/master/src/BUILD.bazel > ./src/BUILD.bazel
curl https://raw.githubusercontent.com/alexeagle/canonical-angularcli-app/master/e2e/protractor.on-prepare.js > ./e2e/protractor.on-prepare.js
curl https://raw.githubusercontent.com/alexeagle/canonical-angularcli-app/master/e2e/BUILD.bazel > ./e2e/BUILD.bazel
curl https://raw.githubusercontent.com/alexeagle/canonical-angularcli-app/236406851409a88e85b3cdc9e6eaa250061fd7cc/src/main.ts > ./src/main.ts
curl https://raw.githubusercontent.com/alexeagle/canonical-angularcli-app/06151761ded53d22a2d03b9e6d67c31f045559af/src/index.html > ./src/index.html
<angular-switchery #f="ngForm" [formControl]="switcheryControl"></angular-switchery>
switcheryControl.value : {{f.value}}
<angular-switchery disabled="disabled"></angular-switchery>
<angular-switchery [(ngModel)]="swticherModel"></angular-switchery>
<angular-switchery [(ngModel)]="swticherModel"></angular-switchery>
Switcher: {{swticherModel? 'ON' : 'OFF'}}
platformBrowserDynamic().bootstrapModule(AppModule, [
{
defaultEncapsulation: ViewEncapsulation.None
}
]);
// 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