Answers for "reload page angular one time"

0

reload page angular one time

ngOnInit() {
  if (!localStorage.getItem('foo')) { 
    localStorage.setItem('foo', 'no reload') 
    location.reload() 
  } else {
    localStorage.removeItem('foo') 
  }
}
Posted by: Guest on June-06-2021
0

refresh data after some time angular

import { Subscription, timer } from 'rxjs';
import { switchMap } from 'rxjs/operators';

subscription: Subscription;
statusText: string;

ngOnInit() {
    this.subscription = timer(0, 10000).pipe(
      switchMap(() => this.myservice.checkdata())
    ).subscribe(result => this.statustext = result);
}

ngOnDestroy() {
    this.subscription.unsubscribe();
}
Posted by: Guest on November-11-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language