This file contains 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 { 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(); |
This file contains 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 { 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(); | |
} |
This file contains 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 { Injectable } from '@angular/core'; | |
@Injectable({ | |
providedIn: 'root' | |
}) | |
export class StoreService { | |
constructor() { | |
console.log('New StoreService instance created'); | |
} |
This file contains 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 { 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) { |
This file contains 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
@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'] |
This file contains 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
@Component({ | |
selector: 'app-timer', | |
template: ` | |
TimerComponent: | |
{{counter}} | |
`, | |
styleUrls: ['./timer.component.scss'] | |
}) | |
export class TimerComponent implements OnInit, OnDestroy { |
This file contains 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, 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'] |
This file contains 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
{ | |
path: 'dynamic-import', | |
loadChildren: () => import('./feature/feature.module').then((m) => m.FeatureModule) | |
} |
This file contains 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
@Component({ | |
selector: 'app-child', | |
template: ` | |
<div class="list-group"> | |
<div class="list-group-item" *ngFor="let item of numbers"> | |
{{item}} | |
</div> | |
</div> | |
`, | |
styleUrls: ['./child.component.scss'], |
This file contains 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
@Component({ | |
selector: 'app-child', | |
template: ` | |
<div class="list-group"> | |
<div class="list-group-item" *ngFor="let item of numbers"> | |
{{item}} | |
</div> | |
</div> | |
`, | |
styleUrls: ['./child.component.scss'], |
NewerOlder