It is generally recommended not to directly interact with the window or any global object. This is because Angular has the capability to run outside of a browser environment, where there may not be a window
or document
available, requiring a safe bridge. The router
feature handles this functionality seamlessly.
Consulting the documentation can provide a clearer understanding:
In a tabbed browser, each tab is represented by its own Window object;
the global window seen by JavaScript code running within a given tab
always represents the tab in which the code is running. Some properties and methods still apply to
the overall window that contains the tab, such as resizeTo() and
innerHeight. Anything that doesn't relate to a specific tab pertains to the window instead.
This behavior is specifically relevant for a tabbed browser. Alternatively, a phone utilizes a different API to access features like the camera, while potentially lacking certain functionalities found on desktop browsers.