Skip to content

Instantly share code, notes, and snippets.

@ssougnez
Last active October 9, 2021 19:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ssougnez/398dfe25424f705a78ae5f2fbeeb0216 to your computer and use it in GitHub Desktop.
Save ssougnez/398dfe25424f705a78ae5f2fbeeb0216 to your computer and use it in GitHub Desktop.
import {
AfterViewInit,
Component,
ComponentFactoryResolver,
Input,
ViewChild,
ViewContainerRef,
} from '@angular/core';
import { HistoryEntry } from './history-entry.model';
@Component({
selector: 'generic-history-entry',
template: `<ng-template #host></ng-template>`,
})
export class GenericHistoryEntryComponent implements AfterViewInit {
@Input()
public entry: HistoryEntry;
@ViewChild('host', { read: ViewContainerRef })
public hostRef: ViewContainerRef;
constructor(private _cfr: ComponentFactoryResolver) {}
public ngAfterViewInit() {
// Instantiate the correct component based on this.entry.type
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment