ngx-modialog: angular2-modal: EXCEPTION: Uncaught (in promise): undefined
I get the following error when I close the modal alert:
core.umd.js:6001 Error: Uncaught (in promise): undefined
at resolvePromise (zone.js:418)
at PromiseCompleter.reject (zone.js:395)
at _dismiss (angular2-modal.umd.js:391)
at eval (angular2-modal.umd.js:394)
at ZoneDelegate.invoke (zone.js:192)
at Object.onInvoke (core.umd.js:8772)
at ZoneDelegate.invoke (zone.js:191)
at Zone.run (zone.js:85)
at zone.js:451
at ZoneDelegate.invokeTask (zone.js:225)
Sample code:
this.modal.alert()
.size("lg")
.showClose(true)
.title("title")
.body("message")
.open();
Dependencies:
"dependencies": {
"@angular/common": "2.0.0-rc.6",
"@angular/compiler": "2.0.0-rc.6",
"@angular/compiler-cli": "0.6.0",
"@angular/core": "2.0.0-rc.6",
"@angular/forms": "2.0.0-rc.6",
"@angular/http": "2.0.0-rc.6",
"@angular/platform-browser": "2.0.0-rc.6",
"@angular/platform-browser-dynamic": "2.0.0-rc.6",
"@angular/router": "3.0.0-rc.2",
"@angular/upgrade": "2.0.0-rc.6",
"core-js": "^2.4.1",
"reflect-metadata": "^0.1.3",
"rxjs": "5.0.0-beta.11",
"systemjs": "0.19.27",
"zone.js": "^0.6.17",
"angular2-in-memory-web-api": "0.0.18",
"angular2-modal": "^2.0.0-beta.10",
"bootstrap": "^3.3.7",
"font-awesome": "^4.6.3",
"jquery": "^3.1.0",
"momentjs": "^1.1.15",
"ng2-translate": "^2.4.4"
},
About this issue
- Original URL
- State: open
- Created 8 years ago
- Reactions: 8
- Comments: 23 (3 by maintainers)
Commits related to this issue
- fix: suppress unhandled rejection closes #188 — committed to shlomiassaf/ngx-modialog by deleted user 8 years ago
You can still use the workaround above, always provide a reject callback:
This exception is thrown when dismissing the dialog, if a reject function was not supplemented. The exception doesn’t really cause any problems. But if you want to get rid of it, from a user perspective, you should make it like:
this.modal.alert().size("lg").showClose(true).title("title").body("message").open().then(result => { result.result.then(() => {}, () => {}); });From the perspective of the library developer, @shlomiassaf could fix it by checking if the reject function actually exists before trying to call it.
I found the problem, need to pass the second param to “then”:
dont works:
dialog.result.then((result) => { console.log(result); });works:
dialog.result.then((result) => { console.log(result); }, () => console.log('Rejected!'));see the suggested PR
This is still an issue. Angular 5.0.1 ngx-modialog 4.0.0-beta.3 zone.js 0.8.18
@JulioC workaround works
@micheltank the second parameter is supposed to be optional.