Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/descriptor.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ angular.module('akoenig.deckgrid').factory('DeckgridDescriptor', [
this.$$deckgrid = null;
this.transclude = true;
this.link = this.$$link.bind(this);

this.templateKeyIndex = 0;
}

/**
Expand All @@ -63,6 +65,8 @@ angular.module('akoenig.deckgrid').factory('DeckgridDescriptor', [
*/
Descriptor.prototype.$$link = function $$link (scope, elem, attrs, nullController, transclude) {
scope.$on('$destroy', this.$$destroy.bind(this));

var templateKey = 'deckgrid/innerHtmlTemplate' + (++this.templateKeyIndex);

if (attrs.cardtemplate === undefined) {
if (attrs.cardtemplatestring === undefined) {
Expand All @@ -81,17 +85,17 @@ angular.module('akoenig.deckgrid').factory('DeckgridDescriptor', [
}
}

$templateCache.put('innerHtmlTemplate', extractedInnerHTML.join());
$templateCache.put(templateKey, extractedInnerHTML.join());
});
} else {
// use the provided template string
//
// note: the attr is accessed via the elem object, as the attrs content
// is already compiled and thus lacks the {{...}} expressions
$templateCache.put('innerHtmlTemplate', elem.attr('cardtemplatestring'));
$templateCache.put(templateKey, elem.attr('cardtemplatestring'));
}

scope.cardTemplate = 'innerHtmlTemplate';
scope.cardTemplate = templateKey;
} else {
// use the provided template file
scope.cardTemplate = attrs.cardtemplate;
Expand Down