Working around browsers' APIs
- #Angular
- #SSR
- #Angular Universal
Working around browsers' APIs
While using Angular SSR, the Universal application does not execute in the browser, and some of the browser APIs and capabilities might be missing on the server.
For example, server-side applications can't reference browser-only global objects such as window, document, navigator, or location.
Angular provides some injectable abstractions over these objects, such as Location or DOCUMENT.
Using DOCUMENT provided Angular injectable abstraction:
import { DOCUMENT } from "@angular/common";
constructor(@Inject(DOCUMENT) private document: Document) {
this.document.location.reload();
}References:
0 Comments
Sign in to join the conversation.