Memory Leak - Forgot to remove the modal attached to scope from ionicModal.fromTemplateUrl
concertcoder opened this issue · comments
Chris Gosselin commented
Hey,
I was going through my project fixing up any memory leaks and I found one in your project.
$ionicModal.fromTemplateUrl('ionic-datepicker-modal.html', {
scope: scope,
animation: 'slide-in-up'
}).then(function (modal) {
scope.modal = modal;
});
The modal attached to scope needs to be cleaned up when the scope is destroyed.
scope.$on('$destroy', function() {
scope.modal.remove();
});
Just put this below that piece of code and it'll fix the memory leak.
Rajeshwar commented
Thanks for pointing it out @concertcoder
Chris Gosselin commented
@rajeshwarpatlolla No problem, thanks for the code ;)