import { Injectable } from '@angular/core'; import { BehaviorSubject } from 'rxjs'; @Injectable({ providedIn: 'root' }) export class LoadingService { private loadingSubject = new BehaviorSubject(false); loading$ = this.loadingSubject.asObservable(); showLoader() { this.loadingSubject.next(true); } hideLoader() { this.loadingSubject.next(false); } }