Dynamically defined data header with ng-table

I am working on using ng-table to display reports as tables. However, I had a problem using the data-title attribute and dynamic header assignment.

In the following example, I am trying to set the data-title attribute as follows.

<td ng-repeat="field in user" data-title="'{{ fields[$index] }}'"> {{ field }} </td> 

$scope.fields = ["Names", "Ages"]; defined inside the controller. When checking an element, the data header attribute is set correctly, but the headers are not processed properly, resulting in the {{fields [$ index]}} header.

Here's a live example: http://plnkr.co/edit/gBS6FGINayYufPGqCMxb?p=preview

+7
angularjs ngtable
source share
1 answer

1stofall, you have unnessesary '' in {{fields[$index]}} .

2nd - yes, it can be dynamic: the mask of an element of an array of fields has a title attribute.

 <table ng-table-dynamic="tableParams with columns" show-filter="false" class="table table-bordered table-striped"> <tbody> <tr ng-repeat="user in $data"> <td ng-repeat="col in $columns">{{user[col.field]}}</td> </tr> </tbody> </table> 

I edited an old example for you, which was on the old ngTable site.

you are using this example - Updated Example 20: Dynamic Columns

0
source share

All Articles