mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 13:02:56 +00:00
change variable
This commit is contained in:
@@ -9,6 +9,7 @@ import { Location } from '@angular/common'
|
||||
export class RouteService {
|
||||
|
||||
history: any = [];
|
||||
liveHistory = [];
|
||||
|
||||
constructor(
|
||||
private router: Router,
|
||||
@@ -23,8 +24,9 @@ export class RouteService {
|
||||
|
||||
const lastRoute = this.history.slice(-1)
|
||||
|
||||
if(event.url != lastRoute) {
|
||||
if (event.url != lastRoute) {
|
||||
this.history.push(event.url)
|
||||
this.liveHistory.push(event.url)
|
||||
this.reduceHistory()
|
||||
}
|
||||
|
||||
@@ -37,16 +39,16 @@ export class RouteService {
|
||||
|
||||
/**
|
||||
* @param url [string] incase no history to go back */
|
||||
goBack(url = null) {
|
||||
if(this.history.length >= 2) {
|
||||
|
||||
goBack(url = null) {
|
||||
if (this.history.length >= 2) {
|
||||
|
||||
|
||||
this.history.pop();
|
||||
const url = this.history.pop();
|
||||
|
||||
this.goTo(url)
|
||||
|
||||
} else if(url) {
|
||||
} else if (url) {
|
||||
this.goTo(url)
|
||||
}
|
||||
|
||||
@@ -58,13 +60,13 @@ export class RouteService {
|
||||
queryParams: this.queryParams(url)
|
||||
}
|
||||
|
||||
const urlObject = new URL('http://localhost:8100'+url);
|
||||
const urlObject = new URL('http://localhost:8100' + url);
|
||||
this.router.navigate([urlObject.pathname], navigationExtras);
|
||||
}
|
||||
|
||||
|
||||
reduceHistory() {
|
||||
if(this.history.length >= 15) {
|
||||
if (this.history.length >= 15) {
|
||||
this.history = this.history.slice(5, this.history.length)
|
||||
}
|
||||
this.LocalstoreService.set('history', this.history)
|
||||
@@ -73,7 +75,7 @@ export class RouteService {
|
||||
|
||||
queryParams(url) {
|
||||
|
||||
const urlObject = new URL('http://localhost:8100'+url);
|
||||
const urlObject = new URL('http://localhost:8100' + url);
|
||||
|
||||
const paramsString = urlObject.search;
|
||||
let searchParams: any = new URLSearchParams(paramsString);
|
||||
@@ -83,7 +85,7 @@ export class RouteService {
|
||||
params[key] = value
|
||||
}
|
||||
|
||||
|
||||
|
||||
return params
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user