import { Component, ComponentFactoryResolver, Injector } from '@angular/core';
import { CustomComponent } from './custom/custom.component';
import swal from 'sweetalert';
@Component({
...
})
export class AppComponent {
constructor( private _resolver: ComponentFactoryResolver,
private _injector : Injector ) {
}
ngOnInit() {
const factory = this._resolver.resolveComponentFactory(CustomComponent);
const component = factory.create(this._injector);
swal({
content: component.location.nativeElement
}).then(() => {
component.destroy();
});
}
}