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-main', | |
template: `<div [innerHTML]="content"></div>`, | |
styles: ['.bold { font-weight: bold; }'], | |
}) | |
export class MainComponent { | |
public content: string = `<p class="bold">I'm the main component</p> | |
<p><a href="/hello">Hello</a></p> | |
<p><a href="https://angular-rxe6rp.stackblitz.io/bye">Bye</a></p> | |
<p><a href="https://www.medium.com">Medium</a></p>`; |
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
<div *ngFor="let entry of entries"> | |
<generic-history-entry [entry]="entry"></generic-history-entry> | |
</div> |
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 { | |
AfterViewInit, | |
Component, | |
ComponentFactoryResolver, | |
Input, | |
ViewChild, | |
ViewContainerRef, | |
} from '@angular/core'; | |
import { BaseHistoryEntryComponent } from './base-history-entry.component'; | |
import { GetHistoryEntryComponent } from './history-entry-type.decorator'; |
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 } from '@angular/core'; | |
import { BaseHistoryEntryComponent } from './base-history-entry.component'; | |
import { HistoryEntryComponent } from './history-entry-type.decorator'; | |
@Component({ | |
selector: 'workflow-ended-history-entry', | |
template: `<div>The workflow took {{ data | number }}ms to complete</div>`, | |
}) | |
@HistoryEntryComponent(3) | |
export class WorkflowEndedHistoryEntryComponent extends BaseHistoryEntryComponent<number> {} |
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
let _bag = new Map<number, any>(); | |
export function HistoryEntryComponent(type: any) { | |
return function (cls: any) { | |
_bag.set(type, cls); | |
}; | |
} | |
export function GetHistoryEntryComponent(type: number) { | |
return _bag.get(type); |
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 { | |
AfterViewInit, | |
Component, | |
ComponentFactoryResolver, | |
Input, | |
ViewChild, | |
ViewContainerRef, | |
} from '@angular/core'; | |
import { HistoryEntry } from './history-entry.model'; |
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 } from '@angular/core'; | |
import { BaseHistoryEntryComponent } from './base-history-entry.component'; | |
@Component({ | |
selector: 'workflow-ended-history-entry', | |
template: `<div>The workflow took {{ data | number }}ms to complete</div>`, | |
}) | |
export class WorkflowEndedHistoryEntryComponent extends BaseHistoryEntryComponent<number> {} |
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 { Directive, Input } from '@angular/core'; | |
@Directive({}) | |
export class BaseHistoryEntryComponent<T> { | |
@Input() | |
public data: T; | |
} |
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
public entries: HistoryEntry[] = [ | |
{ | |
type: 1, | |
data: null, | |
}, | |
{ | |
type: 2, | |
data: '2021-10-09T15:32:15.456Z', | |
}, | |
{ |
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
function foo() { | |
console.log('Hello'); | |
bar(); | |
} | |
function bar() { | |
console.log('Good bye') | |
} |