mirror of
https://github.com/Eugeny/tabby
synced 2024-12-14 15:22:40 +00:00
parent
5eac621ac5
commit
3ceaaec896
1 changed files with 17 additions and 2 deletions
|
@ -1,10 +1,25 @@
|
|||
import { Component, Input } from '@angular/core'
|
||||
import { Component, Input, ViewContainerRef, ViewChild, ComponentFactoryResolver, ComponentRef } from '@angular/core'
|
||||
import { SettingsTabProvider } from '../api'
|
||||
|
||||
@Component({
|
||||
selector: 'settings-tab-body',
|
||||
template: '<ng-container *ngComponentOutlet="provider.getComponentType()"></ng-container>',
|
||||
template: '<ng-template #placeholder></ng-template>',
|
||||
})
|
||||
export class SettingsTabBodyComponent {
|
||||
@Input() provider: SettingsTabProvider
|
||||
@ViewChild('placeholder', {read: ViewContainerRef}) placeholder: ViewContainerRef
|
||||
private component: ComponentRef<Component>
|
||||
|
||||
constructor (private componentFactoryResolver: ComponentFactoryResolver) { }
|
||||
|
||||
ngAfterViewInit () {
|
||||
// run after the change detection finishes
|
||||
setImmediate(() => {
|
||||
this.component = this.placeholder.createComponent(
|
||||
this.componentFactoryResolver.resolveComponentFactory(
|
||||
this.provider.getComponentType()
|
||||
)
|
||||
)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue