likeastore / ngDialog

Modals and popups provider for Angular.js applications
http://likeastore.github.io/ngDialog
3.14k stars 692 forks source link

ngDialog : Uncaught TypeError: Cannot read property 'data' of undefined #577

Open suhasbhatta opened 6 years ago

suhasbhatta commented 6 years ago

ngDialog version : 1.3.0 angular js version : 1.6.4 Affected browser : Google Chrome don't have JSFiddle

I am using ng-dialog with data as options var data = { title : title, msg : msg }; var dialog = ngDialog.open({ template: 'successDialog', plain: false, showClose: true, overlay:false, closeByDocument : true, data:data, className: 'ngdialog-theme-default' });

when i log the data, data is there, still it shows Cannot read property 'data' of undefined

I am expecting to run the ng-dialog without any error. Since it runs in all other occurrences.

mahmah2 commented 4 years ago

It happens to me as well. Not clear what is the reason.

mahmah2 commented 4 years ago

my case was resolved by using local variables as the data storage instead of anonymous data. So instead of using: ngDialog.open({ .... data:{ ..... }, ...... });

I used:

vm.DataForDialog = { .... };
.
.
.
ngDialog.open({  .... data:vm.DataForDialog,  ...... });

And then after, close() method didn't complain about missing data property!