Skip to content

Instantly share code, notes, and snippets.

View alexzuza's full-sized avatar
🎯
Focusing

Alexey Zuev alexzuza

🎯
Focusing
View GitHub Profile
@alexzuza
alexzuza / lazy-load-script.service.ts
Created October 30, 2018 15:42
Load script on demand
import { Injectable, Inject } from '@angular/core';
import { ReplaySubject, Observable } from 'rxjs';
import { DOCUMENT } from '@angular/common';
@Injectable()
export class LazyLoadingScriptService {
_loadedLibraries: { [url: string]: ReplaySubject<any> } = {};
constructor(@Inject(DOCUMENT) private readonly document: any) { }
<div *ngIf="showHelp"
class="context-help-dialog"
(document:click)="documentClicked($event)"
(window:keydown.Escape)="escapedClicked()"
>
{{ content }}
</div>
platformBrowser()
.bootstrapModule(AppModule, { ngZoneEventCoalescing: true });
import { Component, OnInit, Input, ElementRef, HostListener, ViewChild } from '@angular/core';
@Component({
selector: '[context-help]',
templateUrl: './context-help.component.html',
styleUrls: ['./context-help.component.css'],
})
export class ContextHelpComponent {
@Input('context-help') content: string;
<ng-content></ng-content>
<div class="context-help-container" #container>
<i (click)="showHelp = true;"></i>
<div *ngIf="showHelp" class="context-help-dialog">
{{ content }}
</div>
</div>
<h3 context-help="Some description 1">Some title 1</h3>
@alexzuza
alexzuza / with-loading.pipe.ts
Created August 28, 2019 17:50
With loading pipe long living stream
import { Pipe, PipeTransform } from '@angular/core';
import { isObservable, of } from 'rxjs';
import { map, startWith, catchError } from 'rxjs/operators';
@Pipe({
name: 'withLoading',
})
export class WithLoadingPipe implements PipeTransform {
transform(val) {
return isObservable(val)
@alexzuza
alexzuza / with-loading.pipe.ts
Created August 28, 2019 16:52
With loading pipe
import { Pipe, PipeTransform } from '@angular/core';
import { isObservable, of } from 'rxjs';
import { map, startWith, catchError } from 'rxjs/operators';
@Pipe({
name: 'withLoading',
})
export class WithLoadingPipe implements PipeTransform {
transform(val) {
return isObservable(val)
@alexzuza
alexzuza / di_debug_ngmodule_injector.ts
Last active February 20, 2020 22:37
DI debug Root NgModule Injector
ng.probe(getAllAngularRootElements()[0]).injector.view.root.ngModule._providers
@alexzuza
alexzuza / karma.conf.js
Last active September 15, 2019 11:58
angular cli karma config
// Karma configuration file, see link for more information
// https://karma-runner.github.io/0.13/config/configuration-file.html
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular/cli'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),