I'm working on an angular directive to wrap up ng-table with some filtering/exporting functionality. It is aimed to be reusuable for multiple tables so the <td> elements must be dynamic. I am attempting to handle this by using ng-transclude
The problem is that my <td> elements require some directives such as ng-bind,data-title, and sortable. By the time they are attempted to be transcluded by the directive they have already been rendered to empty values. I need a way to prevent the <td> rows from being rendered until they have been inserted into the directive
Here is my view markup:
<div>
<my-data-table search-filter="ss" table-values="mvData">
<td data-title="'UUID' | translate" sortable="'id'" ng-bind="row.uuid | shortUuid"></td>
<td data-title="'DEVICE.UNAME' | translate" sortable="'uname'" ng-bind="row.uname"></td>
<td data-title="'DEVICE.LOGIN' | translate" sortable="'last_login'">{{{true: (row.last_login | selectedTimezone | moment:'MMM D, YYYY h:mma'), false: 'N/A'}[!!row.last_login]}}</td>
</my-data-table>
</div>
The directive template:
<div class="row">
<div class="col-sm-12">
<table ng-table="mvData.tableParams" class="table table-striped table-hover table-bordered" template-pagination="src/tables/responsive-pager.html">
<tr ng-repeat="row in $data">
<div ng-transclude></div>
</tr>
</table>
</div>
</div>
The directive declaration:
angular.module('myApp')
.directive('myDataTable',function() {
return {
restrict:'E'
, templateUrl:'src/tables/myDataTable.tpl.html'
, transclude:true
, scope: {
searchFilter:'='
, tableValues:'='
}
, link:function(scope,el,attr,ctrls) {
console.log('hello world');
}
}
});