Nav.setRoot() does not work

Hi,

I have a button in my app that calls the method submitRequest() defined below:

    <button block (click)="submitRequest()">
           Submit Request
    </button>
    submitRequest() {
        console.log('request submitted');

        var request = this.formAnswers
        request['category'] = this.categoryName 
        
        this.nav.setRoot(Requests);
    }

This works absolutely fine in the browser. When testing on ios device the first time I click the button I get an exception in in the XCode terminal:

.
.
    2016-05-05 22:57:54.937 Projya[4724:2872858] request submitted
    2016-05-05 22:57:54.938 Projya[4724:2872858] ngOnDestroy
    2016-05-05 22:57:54.938 Projya[4724:2872858] EXCEPTION: Error during evaluation of "click"
    2016-05-05 22:57:54.938 Projya[4724:2872858] ERROR: EXCEPTION: Error during evaluation of "click"
    2016-05-05 22:57:54.938 Projya[4724:2872858] ERROR: ORIGINAL EXCEPTION: TypeError: null is not an object (evaluating '_this._el.removeEventListener')
    2016-05-05 22:57:54.938 Projya[4724:2872858] ERROR: ORIGINAL STACKTRACE:
.
.

What’s really strange is that the second time I click - it works just fine.

If I change this like to this.nav.push - everything works as well but the desired behaviour is to set a new root page.

I am using ionic2 beta 6.

Cheers.

Your thread topic talks of .subscribe(), but I’m not seeing it anywhere in your post.

Apologies - I have updated the title.

submitRequest() used to save something to firebase and hence make use of .subscribe() - but I have eliminated that being the cause of the problem - this is happening even after a simple click.

hmmm - seems like this might be the problem…!

1 Like

Mystery solved - Virtual Scroll causes this bug… ! However I still don’t understand why this only shows up when running on the device?