elgervb / ngx-components

Components for Angular
https://stackblitz.com/github/elgervb/ngx-components
0 stars 0 forks source link

create Modal Service #4

Open elgervb opened 7 years ago

elgervb commented 7 years ago

http://blog.brecht.io/Modals-in-angular2/ https://github.com/ng-bootstrap/ng-bootstrap/blob/master/src/modal/modal-stack.ts

elgervb commented 6 years ago

@Injectable(@Injectable({ providedIn: 'root' }) export class ModalService { factoryResolver: ComponentFactoryResolver;

constructor( @Inject(ComponentFactoryResolver) factoryResolver, private injector: Injector ) { this.factoryResolver = factoryResolver; }

open(componentClass: Type): T { const factory = this.factoryResolver .resolveComponentFactory(componentClass); const component = factory .create(rootViewContainer.parentInjector); rootViewContainer.insert(component.hostView); } }