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
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 published message does not contain a solution. When your reputation reaches the required level, you can leave comments on any message ; for now, please make an improvement in your post so that it will answer the question without further clarification from the author . - From the queue of inspections - Yuri
- @Yuri, why is this not an answer? The responder says that the
windowobject is global, as in JavaScript. - ߊߚߤߘ - @Arhad, this response pulls into a comment. To answer you need to attach a code or tell in more detail about solving the problem - Yuri
- I'm new and can't comment on a question. - Nazar Kalytiuk
- Now you can (until with the removal of this answer the reputation for advantages has not rolled back). - ߊߚߤߘ
|
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(); } } |