I created an element directive for a table with data. The table uses ng-repeat
s to render all of the rows/columns.
I created an attribute directive for the element directive. It's purpose is to get the columns you do not wish to include in the table. The full directive might look something like this:
<extended-table exclude="columnone, columntwo"></extended-table>
The table is interpreted as:
<table>
<tr>
<th ng-repeat="column in columns">
{{column}}
</th>
</tr>
<tr ng-repeat="row in data | startFrom:currentRow">
<td ng-repeat="column in columns">
{{row[column]}}
</td>
</tr>
</table>
In the ng-repeat
s, I would like it to ignore the values in exclude, but i'm a bit lost on where to go from here.
app.directive('exclude', function () {
return function (scope, element, attrs) {
var params = attrs.exclude.split(',');
for (var i = 0; i < params.length; i++) {
params[i] = params[i].trim();
}
scope.exclude = params;
};
});
How would I make the ng-repeat
ignore column both for the header and rows if the column is contained within the $scope.exclude
array?
app.filter('startFrom', function () {
return function (input, start) {
start = +start;
return input.slice(start);
};
});