Skip to content

Commit

Permalink
Catch error in case $destroy is called twice
Browse files Browse the repository at this point in the history
This error can happen when using ui-router, as ui-router will manage
your application lifecycle incorrectly. See this issue for more
information:

angular-ui/ui-router#881
  • Loading branch information
Wylie Conlon committed Nov 18, 2014
1 parent c33a714 commit de1ae36
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
7 changes: 5 additions & 2 deletions dist/angular-leaflet-directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,11 @@ angular.module("leaflet-directive", []).directive('leaflet', ["$q", "leafletData
});

scope.$on('$destroy', function () {
map.remove();
leafletData.unresolveMap(attrs.id);
try {
map.remove();
leafletData.unresolveMap(attrs.id);
} catch (e) {
}
});

//Handle request to invalidate the map size
Expand Down
Loading

0 comments on commit de1ae36

Please sign in to comment.