import {ChangeDetectionStrategy, ChangeDetectorRef, Component, OnDestroy} from '@angular/core'; @Component({ selector: 'spinner', imports: [], template: `
{{chars[index]}}
`, changeDetection: ChangeDetectionStrategy.OnPush }) export class SpinnerComponent implements OnDestroy { chars = ['|', '/', '–', '\\']; index = 0; loop = setInterval(() => { this.index = this.index == 3 ? 0 : this.index + 1; this.cdRef.markForCheck(); }, 250); constructor( private cdRef: ChangeDetectorRef ) {} ngOnDestroy() { clearInterval(this.loop); } }