Modal onDidDismiss not returning data


#1

Hi all, I have a modal that returns data when it’s dismissed. Since updating to RC4 the data is always undefined and it throws an error. Anyone experiencing the same issue?

Inside the modal:

itemSelected(order){
let data = {ticketNumber: order.ticketNumber, machineNumber: order.machineNumber};
console.log(JSON.stringify(data)); //prints the data
this.viewCtrl.dismiss(data);
}

In the page opening the modal:

showUrgentOrders():void {
let modal:Modal = this.modalCtrl.create(AlertsModal);
modal.onDidDismiss(order => {
console.log(order); //Always prints undefined
});
modal.present();
}

This is the error printed in the console:

error_handler.js:47 EXCEPTION: Uncaught (in promise): false
ErrorHandler.handleError @ error_handler.js:47
next @ application_ref.js:272
schedulerFn @ async.js:82
SafeSubscriber.__tryOrUnsub @ Subscriber.js:223
SafeSubscriber.next @ Subscriber.js:172
Subscriber._next @ Subscriber.js:125
Subscriber.next @ Subscriber.js:89
Subject.next @ Subject.js:55
EventEmitter.emit @ async.js:74
NgZone.triggerError @ ng_zone.js:278
onHandleError @ ng_zone.js:257
t.handleError @ polyfills.js:3
e.runGuarded @ polyfills.js:3
r @ polyfills.js:3
i @ polyfills.js:3
invoke @ polyfills.js:3
error_handler.js:52 ORIGINAL STACKTRACE:
ErrorHandler.handleError @ error_handler.js:52
next @ application_ref.js:272
schedulerFn @ async.js:82
SafeSubscriber.__tryOrUnsub @ Subscriber.js:223
SafeSubscriber.next @ Subscriber.js:172
Subscriber._next @ Subscriber.js:125
Subscriber.next @ Subscriber.js:89
Subject.next @ Subject.js:55
EventEmitter.emit @ async.js:74
NgZone.triggerError @ ng_zone.js:278
onHandleError @ ng_zone.js:257
t.handleError @ polyfills.js:3
e.runGuarded @ polyfills.js:3
r @ polyfills.js:3
i @ polyfills.js:3
invoke @ polyfills.js:3
error_handler.js:53 Error: Uncaught (in promise): false
at s (polyfills.js:3)
at s (polyfills.js:3)
at polyfills.js:3
at t.invokeTask (polyfills.js:3)
at Object.onInvokeTask (ng_zone.js:227)
at t.invokeTask (polyfills.js:3)
at e.runTask (polyfills.js:3)
at i (polyfills.js:3)
at HTMLDivElement.invoke (polyfills.js:3)
ErrorHandler.handleError @ error_handler.js:53
next @ application_ref.js:272
schedulerFn @ async.js:82
SafeSubscriber.__tryOrUnsub @ Subscriber.js:223
SafeSubscriber.next @ Subscriber.js:172
Subscriber._next @ Subscriber.js:125
Subscriber.next @ Subscriber.js:89
Subject.next @ Subject.js:55
EventEmitter.emit @ async.js:74
NgZone.triggerError @ ng_zone.js:278
onHandleError @ ng_zone.js:257
t.handleError @ polyfills.js:3
e.runGuarded @ polyfills.js:3
r @ polyfills.js:3
i @ polyfills.js:3
invoke @ polyfills.js:3
polyfills.js:3 Error: Uncaught (in promise): false
at s (polyfills.js:3)
at s (polyfills.js:3)
at polyfills.js:3
at t.invokeTask (polyfills.js:3)
at Object.onInvokeTask (ng_zone.js:227)
at t.invokeTask (polyfills.js:3)
at e.runTask (polyfills.js:3)
at i (polyfills.js:3)
at HTMLDivElement.invoke (polyfills.js:3)


#2

After upgrading to RC.4, I am seeing the same error. I have not been able to track down what is causing it but I don’t think it is related to a modal; in fact, I don’t use onDidDismiss() at all. In any case, it doesn’t seem to be breaking anything.

LATER…

I found this https://github.com/driftyco/ionic/issues/9743 which says “Known problem RC4 #9659 Temporary solution is to remove dismissOnPageChange: true and it will work”. And indeed I removed my only use of dismissOnPageChange and my problem went away.


#3

Indeed, it could also be the ViewController


#4

I’m not using “dismissOnPageChange” anywhere, so that doesn’t solve my problem :slight_smile:
Hopefully this is fixed in the full release.


#5

The same issue in the RC5 version:

Error: Uncaught (in promise): false
    at s (polyfills.js:3)
    at s (polyfills.js:3)
    at polyfills.js:3
    at t.invokeTask (polyfills.js:3)
    at Object.onInvokeTask (ng_zone.js:227)
    at t.invokeTask (polyfills.js:3)
    at e.runTask (polyfills.js:3)
    at i (polyfills.js:3)

Ionic Framework: 2.0.0-rc.5
Ionic Native: 2.2.11
Ionic App Scripts: 1.0.0
Angular Core: 2.2.1
Angular Compiler CLI: 2.2.1
Node: 6.9.2
OS Platform: Windows 7
Navigator Platform: Win32


#6

Strange thing: that error occurs after calling submit button in some form and when i moved that button outside the form tag everything work properly. So the working schema is like this:

FormPost component: 

<form>
...
</form>

<button type="button (click)="onSubmit()"></button>
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
onSubmit() {
...
this.viewCtrl.dismiss({ status: "success" });

}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

let modal = this.modalCtrl.create(FormPost, { params: params});
         
            modal.onDidDismiss( (data) => {
       
           if (data && data.status == "success") {
             console.log("success")
          }});
modal.present();

#7

I just tried the conference app by the ionic team which also has a modal returning data. There it does work correctly, so I’m not sure what I’m doing wrong…