Skip to content

Instantly share code, notes, and snippets.

View eliraneliassy's full-sized avatar
:octocat:
Angularing...

Eliran Eliassy eliraneliassy

:octocat:
Angularing...
View GitHub Profile
constructor(@Self() public controlDir: NgControl) {
this.control.valueAccessor = this;
}
export class FirstCustomInputComponent {
@Input() type = 'text';
@Input() isRequired: boolean = false;
@Input() pattern: string = null;
@Input() label: string = null;
@Input() placeholder: string;
@Input() errorMsg: string;
}
setTimeout(async () => {
this.predictions = await this.model.classify(this.img.nativeElement);
});Ï
import { enableProdMode, NgModuleRef } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app/app.module';
import { environment } from './environments/environment';
import { createCustomElement } from '@angular/elements';
import { MyElementComponent } from 'my-element';
if (environment.production) {
enableProdMode();
import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app/app.module';
import { environment } from './environments/environment';
if (environment.production) {
enableProdMode();
}
@eliraneliassy
eliraneliassy / store.service.ts
Created March 21, 2020 12:48
store.service.ts
import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class StoreService {
constructor() {
console.log('New StoreService instance created');
}
import { Subscription } from 'rxjs';
export function Unsubscriber() {
return (cmpType) => {
const originalFactory = cmpType.ngComponentDef.factory;
cmpType.ngComponentDef.factory = (...args) => {
const cmp = originalFactory(...args);
cmpType.ngComponentDef.onDestroy = () => {
if (cmp.ngOnDestroy) {
@Component({
selector: 'app-timer-example',
template: `
<div>
<app-timer *ngIf="alive"></app-timer>
</div>
<button (click)="destroy()" class="btn btn-danger">Destroy</button>
<button (click)="revive()" class="btn btn-primary">Revive</button>
`,
styleUrls: ['./timer-example.component.scss']
@Component({
selector: 'app-timer',
template: `
TimerComponent:
{{counter}}
`,
styleUrls: ['./timer.component.scss']
})
export class TimerComponent implements OnInit, OnDestroy {
import { Component, OnInit, ɵrenderComponent, ɵɵdirectiveInject, INJECTOR, Injector } from '@angular/core';
@Component({
selector: 'app-feature',
template: `
<button class="btn btn-primary" (click)="loadCounter()">Load Counter</button>
<my-host></my-host>
`,
styleUrls: ['./feature.component.scss']