angular-fancy-modal icon indicating copy to clipboard operation
angular-fancy-modal copied to clipboard

Uncaught TypeError: Cannot read property '$destroy' of undefined

Open b1r3k opened this issue 9 years ago • 5 comments

Internals of this module throw TypeError exception while modal is being dismissed

cleanUp @   angular-fancy-modal.js:96
(anonymous function)    @   angular-fancy-modal.js:127
eventHandler    @   angular.js:3032

My controller:

    .controller('SessionCtrl', function ($scope, $fancyModal) {
        var modalOpt = {
            templateUrl: 'views/session/greeting.html'
        };
        $fancyModal.open(modalOpt);
    });

debugger says that $modal.scope() returns undefined

BTW, I'm experiencing that while using angularjs 1.3.15

b1r3k avatar May 27 '15 13:05 b1r3k

could you please set up a jsfiddle?

vesparny avatar May 27 '15 13:05 vesparny

Yeah, sure: http://embed.plnkr.co/DpTYA4cOh44iwKeXNdef/

I'm almost sure it's related to the debug info. It will work if you will remove this block:

app.config(function ($compileProvider, $logProvider) {
  $compileProvider.debugInfoEnabled(false);
  $logProvider.debugEnabled(false);
});

Check out changes between 1.3.x and 1.2.x for angular.element: https://code.angularjs.org/1.3.3/docs/api/ng/function/angular.element

b1r3k avatar May 27 '15 13:05 b1r3k

I guess it's because

$compileProvider.debugInfoEnabled(false);

This line basically makes impossible to retrieve the scope from an angular.element for some reason.

I also see this.

https://docs.angularjs.org/guide/production#disabling-debug-data

Probably the only solution is to avoid getting the scope from DOM element. To do so I should probably keep track of created scope in some different way.

vesparny avatar May 27 '15 14:05 vesparny

yeah this will be breaking change if this module wants to be compatible with 1.3.x maybe you could track $destroy event of that DOM element instead (it's available even with debug info disabled)

b1r3k avatar May 27 '15 14:05 b1r3k

what do you mean?

vesparny avatar May 27 '15 14:05 vesparny