Files
redash/client/app/components/dynamic-table/dynamic-table-row.js
2018-01-18 12:26:49 +02:00

26 lines
673 B
JavaScript

import { isFunction } from 'underscore';
export default function init(ngModule) {
ngModule.directive('dynamicTableRow', () => ({
template: '',
// AngularJS has a strange love to table-related tags, therefore
// we should use this directive as an attribute
restrict: 'A',
replace: false,
scope: {
columns: '=',
row: '=',
render: '=',
},
link: ($scope, $element) => {
$scope.$watch('render', () => {
if (isFunction($scope.render)) {
$scope.render($scope, (clonedElement) => {
$element.empty().append(clonedElement).append('<td></td>');
});
}
});
},
}));
}