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
| const nums = [1,2,3,4,5]; | |
| // your own | |
| const reduce = (arr, fn, initValue) => { | |
| let result = initValue; | |
| arr.forEach( item => result = fn(result, item) ); | |
| return result; | |
| } | |
| console.log(reduce(nums, (total, item) => total + item , 0)) |
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
| function copyStyles(sourceDoc, targetDoc) { | |
| Array.from(sourceDoc.styleSheets).forEach(styleSheet => { | |
| if (styleSheet.cssRules) { | |
| const newStyleEl = sourceDoc.createElement('style'); | |
| Array.from(styleSheet.cssRules).forEach(cssRule => { | |
| newStyleEl.appendChild(sourceDoc.createTextNode(cssRule.cssText)); | |
| }); | |
| targetDoc.head.appendChild(newStyleEl); |
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 { | |
| AfterViewInit, | |
| Component, | |
| ComponentFactoryResolver, | |
| ComponentRef, | |
| Injector, | |
| ViewChild, | |
| ViewContainerRef, | |
| ViewRef | |
| } from '@angular/core'; |
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 { | |
| ChangeDetectorRef, | |
| Component, | |
| ComponentFactory, | |
| ComponentFactoryResolver, | |
| ElementRef, | |
| Injector, | |
| OnInit, | |
| Renderer2, | |
| ViewChild, |
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 {AfterViewInit, Component, OnInit, TemplateRef, ViewChild, ViewContainerRef,} from '@angular/core'; | |
| @Component({ | |
| selector: 'app-root', | |
| template: ` | |
| <div class="container"> | |
| <h1 class="display-1">Angular<span class="text-muted">MasterClass</span></h1> | |
| <ng-container #container></ng-container> | |
| <ng-container *ngIf="condition as value">{{ value }}</ng-container> |
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 {AfterViewInit, Component, OnInit, TemplateRef, ViewChild, ViewContainerRef,} from '@angular/core'; | |
| import {Card, CardTypes} from "./cards/card.types"; | |
| @Component({ | |
| selector: 'app-root', | |
| template: ` | |
| <div class="container"> | |
| <h1 class="display-1">Angular<span class="text-muted">MasterClass</span></h1> | |
| <!-- will render the built-in templates --> |
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} from '@angular/core'; | |
| import {FormControl} from "@angular/forms"; | |
| @Component({ | |
| selector: 'app-root', | |
| template: ` | |
| <h1>Angular Playground</h1> | |
| <input type="password" | |
| [formControl]="inputControl" | |
| nkStrongPassword |
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 {AfterViewInit, Component, QueryList, ViewChildren} from '@angular/core'; | |
| import {NgComponentOutlet} from "@angular/common"; | |
| // Something to loop over | |
| @Component({ | |
| template: `<p>Component Type A</p>` | |
| }) | |
| class ComponentA {} | |
| @Component({ |
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 {BehaviorSubject, Observable} from "rxjs"; | |
| import {Inject, Injectable, InjectionToken} from "@angular/core"; | |
| export interface Action { | |
| type: string; | |
| } | |
| export interface ActionHandler { | |
| handleAction(currentState: any, action: Action): 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
| const website = `nir.life` | |
| const btn = document.createElement('button'); | |
| function map(transformFn) { | |
| return function(inputValueProvider) { | |
| return createObservable( | |
| function (onValue, onError, onComplete) { | |
| inputValueProvider.subscribe( | |
| (value) => onValue(transformFn(value)), |
OlderNewer