import { Injectable } from '@angular/core' ; @ Injectable ( ) export class ModalService { private modals : any [ ] = [ ] ; constructor ( ) { } add ( modal ) { this . modals . push ( modal ) ; } remove ( id ) { this . modals = this . modals . filter ( x => x . id !== id ) ; } open ( id ) { const modal = this . modals . find ( x => x . id === id ) ; modal . open ( ) ; } close ( id ) { const modal = this . modals . find ( x => x . id === id ) ; modal . close ( ) ; } }