mirror of
https://github.com/eugeny/tabby
synced 2026-09-17 02:25:55 +00:00
34 lines
1.0 KiB
TypeScript
34 lines
1.0 KiB
TypeScript
import { Component, Input, ViewContainerRef, ViewChild, ComponentFactoryResolver, ComponentRef } from '@angular/core'
|
|
import { SettingsTabProvider } from '../api'
|
|
|
|
/** @hidden */
|
|
@Component({
|
|
selector: 'settings-tab-body',
|
|
template: '<ng-template #placeholder></ng-template>',
|
|
styles: [`
|
|
:host {
|
|
display: block;
|
|
padding-bottom: 20px;
|
|
max-width: 500px;
|
|
}
|
|
`],
|
|
})
|
|
export class SettingsTabBodyComponent {
|
|
@Input() provider: SettingsTabProvider
|
|
@ViewChild('placeholder', { read: ViewContainerRef }) placeholder: ViewContainerRef
|
|
component: ComponentRef<unknown>
|
|
|
|
constructor (private componentFactoryResolver: ComponentFactoryResolver) { }
|
|
|
|
ngAfterViewInit (): void {
|
|
// run after the change detection finishes
|
|
setImmediate(() => {
|
|
this.component = this.placeholder.createComponent(
|
|
this.componentFactoryResolver.resolveComponentFactory(
|
|
this.provider.getComponentType(),
|
|
),
|
|
)
|
|
})
|
|
}
|
|
}
|