Files
doneit-web/src/app/services/active-tab.service.ts
T
2023-02-08 09:53:21 +01:00

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
}
}
}