harish mahajan harish mahajan - 1 year ago 229
TypeScript Question

How to get height and width of device in angular2 using typescript?

I found this solution. Is it valid?

import {Component} from '@angular/core';
import {Platform} from 'ionic-angular';

export MyApp {
constructor(platform: Platform) {
platform.ready().then((readySource) => {
console.log('Width: ' + platform.width());
console.log('Height: ' + platform.height());

This solution is for ionic 2.
can i also used for angular 2?

Please suggest me the right way to do it.

Answer Source
export class Dashboard {
    innerHeight: any;
    innerWidth: any;
    constructor(private router: Router, private http: Http) {
        this.innerHeight = (window.screen.height) + "px";
        this.innerWidth = (window.screen.width) + "px";
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download