angular javascript document and window functions best practice

In angular component.ts I use ngOnInit function to implement Javascript document and window functions.

for example :

ngOnInit(): void {
  document.addEventListener('mouseup', () => {
    this.isRatingPopupActive = false;
  });
}

this is part of my code to close opened popup after mouseup similar to facebook like button .. is this right?

and if it is wrong to use onInit this way, what is the best practice then?

thank you all <3