This repository was archived by the owner on Sep 20, 2019. It is now read-only.

Description
Hi there !
If you use an angularjs directive as a marker popup, when the marker is remove from path the $destroy() method is not call. It's a big problem when you deal with popups that use two way binding or watchers, because they continue to live after the marker death ! This is a conceptual bug, who can potentially inflate memory and/or CPU.
I've done a jsfiddle with a corrected version of ui-leaflet.js who send a $destroy()on the $scope of popup directive. The directive finally receive the $destroy event and can do garbage stuff.
Sorry if the fiddle is a little bit crowded, but I had to past all the ui-leaflet code in the javascript section. Just look at the very last lines, they describe a little angular app.
The way it works => jsFiddle :
- First ADD a marker with button. This will create marker with directive popup and a
$new() scope.
- Then launch the popup by clicking on the marker. This will start a timer, have a look to the
console.
- At least REMOVE the marker with button. This will remove it from path and trigger the
$destroy event and let a chance to the directive to stop the timer and also, deeper inside Angular, kill the watchers for two way binding.
What I've done to correct it :
At the end of _deleteMarker : markerData.getMessageScope().$destroy();

Can we rapidly mastering this evolution ? Pull request ?
Vincent