Skip to content

Instantly share code, notes, and snippets.

@codewithsrini
Created July 16, 2020 13:30
Show Gist options
  • Save codewithsrini/132dbe793914e8a525e30d1d6a114397 to your computer and use it in GitHub Desktop.
Save codewithsrini/132dbe793914e8a525e30d1d6a114397 to your computer and use it in GitHub Desktop.
import { Component, OnInit, ChangeDetectorRef } from '@angular/core';
import { SpinnerService } from './spinner.service';
@Component({
selector: 'app-spinner',
templateUrl: './spinner.component.html',
styleUrls: ['./spinner.component.scss']
})
export class SpinnerComponent implements OnInit {
showSpinner = false;
constructor(private spinnerService: SpinnerService, private cdRef: ChangeDetectorRef) {
}
ngOnInit() {
this.init();
}
init() {
this.spinnerService.getSpinnerObserver().subscribe((status) => {
this.showSpinner = (status === 'start');
this.cdRef.detectChanges();
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment