Skip to content

Commit

Permalink
Merge pull request #33 from elado/master
Browse files Browse the repository at this point in the history
Multiple grids on page with cardTemplateString use the last template available
  • Loading branch information
André König committed Mar 16, 2014
2 parents 613f5ad + b94ea81 commit 7e97ef1
Showing 1 changed file with 7 additions and 3 deletions.
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

0 comments on commit 7e97ef1

Please sign in to comment.