Skip to content

Commit

Permalink
Fixing html support
Browse files Browse the repository at this point in the history
  • Loading branch information
iamisti committed Sep 12, 2016
1 parent 2906d80 commit 914ab54
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(function(){
'use strict';

function mdtAddHtmlContentToCellDirective($parse, $compile){
function mdtAddHtmlContentToCellDirective($parse, $compile, $rootScope){
return {
restrict: 'A',
require: '^mdtTable',
Expand All @@ -22,14 +22,15 @@
var customCellData = ctrl.tableDataStorageService.customCells[originalValue.columnKey];

var clonedHtml = customCellData.htmlContent;
var localScope = customCellData.scope;

//append value to the scope
var localScope = $rootScope.$new();
localScope.value = val;

$compile(clonedHtml)(localScope, function(cloned){
element.append(cloned);
});

}else{
element.append(val);
}
Expand Down
3 changes: 0 additions & 3 deletions app/modules/main/directives/helpers/mdtCustomCellDirective.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@
transclude(function (clone) {
var columnKey = attrs.columnKey;

// since user can have custom bindings inside the transcluded content, we have to store
// scope as well, to be able to compile the html content with the right scope context
ctrl.tableDataStorageService.customCells[columnKey] = {
scope: $scope.$parent.$parent,
htmlContent: clone.clone()
};
});
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "md-data-table",
"version": "1.6.7",
"version": "1.6.8",
"homepage": "https://github.com/iamisti/mdDataTable",
"author":"Istvan Fodor <[email protected]>",
"main": [
Expand Down
10 changes: 4 additions & 6 deletions dist/md-data-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -1216,8 +1216,8 @@
(function(){
'use strict';

mdtAddHtmlContentToCellDirective.$inject = ['$parse', '$compile'];
function mdtAddHtmlContentToCellDirective($parse, $compile){
mdtAddHtmlContentToCellDirective.$inject = ['$parse', '$compile', '$rootScope'];
function mdtAddHtmlContentToCellDirective($parse, $compile, $rootScope){
return {
restrict: 'A',
require: '^mdtTable',
Expand All @@ -1238,14 +1238,15 @@
var customCellData = ctrl.tableDataStorageService.customCells[originalValue.columnKey];

var clonedHtml = customCellData.htmlContent;
var localScope = customCellData.scope;

//append value to the scope
var localScope = $rootScope.$new();
localScope.value = val;

$compile(clonedHtml)(localScope, function(cloned){
element.append(cloned);
});

}else{
element.append(val);
}
Expand Down Expand Up @@ -1293,10 +1294,7 @@
transclude(function (clone) {
var columnKey = attrs.columnKey;

// since user can have custom bindings inside the transcluded content, we have to store
// scope as well, to be able to compile the html content with the right scope context
ctrl.tableDataStorageService.customCells[columnKey] = {
scope: $scope.$parent.$parent,
htmlContent: clone.clone()
};
});
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "md-data-table",
"version": "1.6.7",
"version": "1.6.8",
"author": "Istvan Fodor <[email protected]>",
"registry": "github",
"repository": {
Expand Down

0 comments on commit 914ab54

Please sign in to comment.