Last active
January 29, 2024 12:34
-
-
Save HilquiasAbias/2b7177661db9277dcd7e3c5f17e44aca to your computer and use it in GitHub Desktop.
reload service angular
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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