Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: TypeError: Cannot read property 'direction' of null #5737

Closed
iignatov opened this issue Mar 6, 2016 · 4 comments
Closed

bug: TypeError: Cannot read property 'direction' of null #5737

iignatov opened this issue Mar 6, 2016 · 4 comments

Comments

@iignatov
Copy link
Contributor

iignatov commented Mar 6, 2016

Short description of the problem:

The following exception is thrown when using the ViewController.dismiss() method:
TypeError: Cannot read property 'direction' of null

What behavior are you expecting?

I'm expecting that ViewController.dismiss() should be working similar to NavController.pop(), although I'm using Ionic for only 1 week and maybe I'm missing something or using something incorrectly.

Steps to reproduce:

  1. Click the Profile button on HomePage, bound to HomePage.profile().
  2. Click the Logout button on ProfilePage, bound to ProfilePage.logout().
  3. The following exception is thrown:
Uncaught EXCEPTION: Error during evaluation of "click"
ORIGINAL EXCEPTION: TypeError: Cannot read property 'direction' of null
ORIGINAL STACKTRACE:
TypeError: Cannot read property 'direction' of null
    at NavController.remove (http://localhost:8100/build/js/app.bundle.js:47600:31)
    at ViewController.dismiss (http://localhost:8100/build/js/app.bundle.js:45635:27)
    at ProfilePage.logout (http://localhost:8100/build/js/app.bundle.js:62635:20)
    at AbstractChangeDetector.ChangeDetector_ProfilePage_0.handleEventInternal (viewFactory_ProfilePage:186:31)
    at AbstractChangeDetector.handleEvent (http://localhost:8100/build/js/app.bundle.js:14022:30)
    at AppView.triggerEventHandlers (http://localhost:8100/build/js/app.bundle.js:18329:37)
    at eval (viewFactory_ProfilePage:605:110)
    at http://localhost:8100/build/js/app.bundle.js:33400:37
    at http://localhost:8100/build/js/app.bundle.js:32777:87
    at Zone.run (http://localhost:8100/build/js/app.bundle.js:2258:25)

Code:

@Page({
    ...
})
export class HomePage {
    constructor(private nav: NavController) {
        ...
    }

    profile() {
        this.nav.push(ProfilePage, { ... });
    }
}

@Page({
    ...
})
export class ProfilePage {
    constructor(params: NavParams, private nav: NavController, private view: ViewController) {
        ...
    }

    logout() {
        ...
        // Error when executing the following:
        this.view.dismiss(null);
        // It works OK rewritten this way though:
        // this.nav.pop();
    }
}

Ionic Version: 2.x

Browser & Operating System: Chrome (Windows 8.1 64-bit)

Run ionic info from terminal/cmd prompt:

Your system information:

Cordova CLI: 6.0.0
Ionic Version: 2.0.0-beta.1
Ionic CLI Version: 2.0.0-beta.17
Ionic App Lib Version: 2.0.0-beta.8
OS: Windows 8.1
Node Version: v5.6.0
@Ionitron Ionitron added the v2 label Mar 6, 2016
@adamdbradley
Copy link
Contributor

Good catch! This issue helped expose some problems with how we were generating navigation opts objects when the argument was missing, or it had an undefined or null value. Should be fixed in the next release, thanks for the help!

@iignatov
Copy link
Contributor Author

iignatov commented Mar 7, 2016

Wow, that was fast. Thanks for the reply and the quick fix! Looking forward to the next release.

@cperez87
Copy link

Hi, Im having a very similar problem even after upgrading to latest ionic version.
Cordova CLI: 6.0.0
Ionic Version: 2.0.0-beta.3
Ionic CLI Version: 2.0.0-beta.23
Ionic App Lib Version: 2.0.0-beta.13
OS:
Node Version: v5.7.0

In my case, when I try to do this.viewCtrl.dismiss(), im getting Cannot read property 'removeEventListener' of null. That is, when I have an ion-infinite-scroll on the page.

I have tried using this.nav.pop() and this.nav.popToRoot() and still get the same issue.
The only things that has worked is removing the infinite scroll. But I need it.

Any suggestions?
Thank you

@iignatov
Copy link
Contributor Author

iignatov commented Apr 2, 2016

@cperez1087 This is a known issue and will be fixed in beta.4.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Sep 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants