Answer the question
In order to leave comments, you need to log in
How to access a variable from another component?
The component has a variable that is responsible for the timer (time of user inactivity).
timer: number;
...
ngAfterViewInit(): void {
this.timer = 0;
setInterval( () => {
this.timer ++;
}, 1000);
}
@HostListener('window:mousemove', ['$event'])
refreshTimer(e: MouseEvent): any {
this.timer = 0;
}
Answer the question
In order to leave comments, you need to log in
You do not need to access the component field, you need to keep this data in the service, and pick it up and display it in the component.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question