I am facing an issue where I want to declare HTMLElement variables accessible to all functions within a particular class. Despite my efforts, declaring it before the constructor and assigning its value inside the constructor is not working as expected. Strangely, when I declare and assign the variable within a specific function like `employeesClick()`, it works fine.
My goal is to avoid repeating the same code multiple times since I need to modify other buttons based on the one that was clicked.
Although there are no visible errors, nothing seems to happen. Can anyone guide me on how to achieve this?
export class HeaderComponent implements OnInit {
projects:HTMLElement;
constructor() {
this.projects=document.getElementById('projects');
}
ngOnInit() {
}
projectsClick(){
this.projects.style.color="#DEA731";
}
employeesClick(){
var employees : HTMLElement = document.getElementById('employees');
employees.style.color="#DEA731";
}
}