akoenig / angular-deckgrid

A lightweight masonry-like grid for AngularJS.
http://akoenig.github.io/angular-deckgrid
MIT License
1.1k stars 191 forks source link

Fix a bug about destroy #108

Open maxight opened 8 years ago

maxight commented 8 years ago

Bug: when we switch from one state (page) to another, and we have deckgrid in both states, then new deckgrid is created, then destroy is called... but is called for just created new deckgrid instead of old one.

Reason: angular calls directive function only once. So that we always have the only instance of Descriptor (and several inctances of Deckgrid). Hence, descriptor.$$deckgrid will always point to the recently assigned deckgrid.

Fix: instead of using $$destroy in Descriptor (that has one instance only), use destroy of deckgrid directly (specifying correct instance of DeckGrid, so that I bind it to just created instance of DeckGrid in $$link function).