12345678910111213141516171819202122232425262728 |
- import { Injectable } from '@angular/core';
- import { Subject } from 'rxjs';
- @Injectable({
- providedIn: 'root',
- })
- export class DetailsService {
- private detailsPanelSubject = new Subject<any>();
- detailsPanel$ = this.detailsPanelSubject.asObservable();
- private closePanelSubject = new Subject<any>();
- closePanel$ = this.closePanelSubject.asObservable();
- private resultSubject = new Subject<any>();
- result$ = this.resultSubject.asObservable();
- public openPanel(component: any, data: any) {
- this.detailsPanelSubject.next({ component, data });
- }
- // Is called from the dynamic component to close the offcanvas
- public closePanel(result: any, data?: any) {
- // console.log('closePanel', result);
- // Is listened to in the host component where the panel was opened, to initiate further steps
- this.resultSubject.next({ state: result, data: data });
- this.closePanelSubject.next('close');
- }
- }
|