import { Injectable } from '@angular/core' ; import { Store } from '@ngrx/store' ; import { DomService , ChildConfig } from './dom.service' ; import { AppState } from '../store' ; import { OpenModalAction , CloseModalAction } from '../store/actions/modal.actions' ; @ Injectable ( ) export class ModalService { constructor ( private store$ , private dom ) { } private modalSelector = '.modal' ; open ( component , inputs = { } , outputs = { } ) { let componentConfig = { inputs , outputs } ; this . dom . appendComponentTo ( this . modalSelector , component , componentConfig ) ; this . store$ . dispatch ( new OpenModalAction ( ) ) ; } close ( ) { this . dom . removeComponent ( ) ; this . store$ . dispatch ( new CloseModalAction ( ) ) ; } }