Can someone tell me how to change the properties of the browser window on Angular 2 - resolution, orientation. I understand that you need to use the window object - just how to get to it using Typescript?

  • declare var window: any; - Serginio

2 answers 2

Yes, as well as in js. There is an object window and it will even be here with autocompletion, since it is strict typing.

The most kosher option is to create a service and inject it into the necessary components.

 import { Injectable } from '@angular/core'; function _window() : any { return window; } @Injectable() export class WindowRef { get nativeWindow() : any { return _window(); } }