diff --git a/angular-deckgrid.js b/angular-deckgrid.js index e57bda8..1285dd5 100644 --- a/angular-deckgrid.js +++ b/angular-deckgrid.js @@ -78,17 +78,6 @@ angular.module('akoenig.deckgrid').factory('DeckgridDescriptor', [ } - /** - * @private - * - * Cleanup method. Will be called when the - * deckgrid directive should be destroyed. - * - */ - Descriptor.prototype.$$destroy = function $$destroy () { - this.$$deckgrid.destroy(); - }; - /** * @private * @@ -98,8 +87,6 @@ angular.module('akoenig.deckgrid').factory('DeckgridDescriptor', [ Descriptor.prototype.$$link = function $$link (scope, elem, attrs, nullController, transclude) { var templateKey = 'deckgrid/innerHtmlTemplate' + (++this.$$templateKeyIndex) + '.html'; - scope.$on('$destroy', this.$$destroy.bind(this)); - if (angular.isUndefined(attrs.cardtemplate)) { if (angular.isUndefined(attrs.cardtemplatestring)) { // use the provided inner html as template @@ -136,6 +123,8 @@ angular.module('akoenig.deckgrid').factory('DeckgridDescriptor', [ scope.mother = scope.$parent; this.$$deckgrid = Deckgrid.create(scope, elem[0]); + + scope.$on('$destroy', this.$$deckgrid.destroy.bind(this.$$deckgrid)); }; return {