From b94ea81ac5fcc467f2b74f37df098532818a7e92 Mon Sep 17 00:00:00 2001 From: Elad Ossadon Date: Fri, 28 Feb 2014 17:11:30 -0800 Subject: [PATCH] Use unique template key. Fixes #32 --- src/descriptor.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/descriptor.js b/src/descriptor.js index ae10649..1d70674 100644 --- a/src/descriptor.js +++ b/src/descriptor.js @@ -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; } /** @@ -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) { @@ -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;