mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 04:57:52 +00:00
50 lines
1.1 KiB
TypeScript
50 lines
1.1 KiB
TypeScript
|
|
import { Injectable } from '@angular/core';
|
||
|
|
import { Router } from '@angular/router';
|
||
|
|
|
||
|
|
@Injectable({
|
||
|
|
providedIn: 'root'
|
||
|
|
})
|
||
|
|
export class ActiveTabService {
|
||
|
|
|
||
|
|
pages = {
|
||
|
|
chat: false,
|
||
|
|
agenda: false,
|
||
|
|
publication: false,
|
||
|
|
home: false,
|
||
|
|
gabinete: false
|
||
|
|
}
|
||
|
|
|
||
|
|
constructor(private router: Router) {
|
||
|
|
|
||
|
|
this.detectActiveTab()
|
||
|
|
|
||
|
|
this.router.events.subscribe((val) => {
|
||
|
|
this.detectActiveTab()
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
detectActiveTab() {
|
||
|
|
this.setFalseToAllPage();
|
||
|
|
const pathName = window.location.pathname
|
||
|
|
|
||
|
|
if(pathName.startsWith('/home/agenda')) {
|
||
|
|
this.pages.agenda = true
|
||
|
|
} else if (pathName.startsWith('/home/events')) {
|
||
|
|
this.pages.home = true
|
||
|
|
} else if (pathName.startsWith('/home/gabinete-digital')) {
|
||
|
|
this.pages.gabinete = true
|
||
|
|
} else if (pathName.startsWith('/home/publications')) {
|
||
|
|
this.pages.publication = true
|
||
|
|
} else if (pathName.startsWith('/home/chat')) {
|
||
|
|
this.pages.chat = true
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
setFalseToAllPage() {
|
||
|
|
for( const page in this.pages) {
|
||
|
|
this.pages[page] = false
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|