Errror when setting page as rootPage : Uncaught TypeError: Cannot read property 'ev' of null


#1

Hello,
I have this issue I dont know if it’s an ionic 2 bug or if I need support

Ionic version: 2.x

Current behavior:
I have a menu in my app, and when I logged out, I want to set LoginPage as root page.
this.nav.setRoot(LoginPage);
But I have below error :

Error:

    \node_modules\ionic-angular\util\dom-controller.js:94 Uncaught TypeError: Cannot read property 'ev' of null
        at Content.readDimensions (\node_modules\ionic-angular\components\content\content.js:518)
        at dispatch (\node_modules\ionic-angular\util\dom-controller.js:103)
        at DomController.flush (\node_modules\ionic-angular\util\dom-controller.js:84)
        at rafCallback (\node_modules\ionic-angular\util\dom-controller.js:77)
    Content.readDimensions @ \node_modules\ionic-angular\components\content\content.js:518
    dispatch @ \node_modules\ionic-angular\util\dom-controller.js:103
    DomController.flush @ \node_modules\ionic-angular\util\dom-controller.js:84
    rafCallback @ \node_modules\ionic-angular\util\dom-controller.js:77
    \node_modules\ionic-angular\animations\animation.js:291 Uncaught TypeError: _this._raf is not a function
        at eval (\node_modules\ionic-angular\animations\animation.js:291)

Related code:

import { Component, ViewChild} from '@angular/core';
import { Platform, Nav, LoadingController, MenuController,Events} from 'ionic-angular';
import {HomePage} from '../pages/home/home';
import {LoginPage} from '../pages/login/login';
import {UserService} from '../services/user.service';

@Component({
  templateUrl: 'app.html'
})
export class App {
    @ViewChild(Nav) nav:Nav;
    rootPage: any=HomePage;

    constructor(public userService:UserService)
    {
       ......
    }

 doLogout()
  {
     this.userService.doLogout().subscribe(res=>{
         if(res.success)
         {
            localStorage.removeItem('isLoggedIn');
            localStorage.removeItem('loggedUserInfo');
            this.menu.close();
            this.nav.setRoot(LoginPage);
         }
     });
  }
}

Ionic info::

Cordova CLI: 6.3.1
Ionic Framework Version: 2.0.0-rc.4
Ionic CLI Version: 2.1.18
Ionic App Lib Version: 2.1.9
Ionic App Scripts Version: 0.0.4
ios-deploy version: Not installe
ios-sim version: Not installed
OS: Windows 7
Node Version: v4.6.0
Xcode version: Not installed```

#2

Could you put together a simple demo and push it to github? Kind of hard to know what the issue is without one


#3

@mhartington I face now the same issue as on this topic Ionic 2 - Page freeze after navCtrl.setRoot(LoginPage) :disappointed_relieved:


#4

Hey guys, awesome work, did anyone find a fix for this?


#5

Not sure if this is any help but I get a similar error when unit testing, though my error is at line 112 in ionic-angular/platform/dom-controller.js.

I was following this tutorial:


#6

I’m same error.

Uncaught TypeError: Cannot read property ‘ev’ of null
at Content._readDimensions (content.js:526)
at content.js:155
at dispatch (dom-controller.js:128)
at DomController._flush (dom-controller.js:102)
at rafCallback (dom-controller.js:95)


#7

Solution in this link


#8

I used below code in app.component to set root and it works.


@ViewChild(Nav) nav: Nav;

this.nav.setRoot('login', {}, { animate: true, direction: 'forward' });;