Skip to content

Instantly share code, notes, and snippets.

@HilquiasAbias
Last active January 29, 2024 12:34
Show Gist options
  • Save HilquiasAbias/2b7177661db9277dcd7e3c5f17e44aca to your computer and use it in GitHub Desktop.
Save HilquiasAbias/2b7177661db9277dcd7e3c5f17e44aca to your computer and use it in GitHub Desktop.
reload service angular
import { Injectable } from '@angular/core';
import { Router } from '@angular/router';
@Injectable({
providedIn: 'root'
})
export class ReloadService {
url: string;
constructor(public router:Router) {
this.url = this.router.url;
}
self() {
this.router.navigateByUrl('/',{skipLocationChange:true}).then(()=>{
this.router.navigate([this.url]);
})
}
component(url:string) {
this.router.navigateByUrl('/',{skipLocationChange:true}).then(()=>{
this.router.navigate([url]);
})
}
app() {
window.location.reload();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment