I'm using AngularJS in my project !
I have following JSON
{
"headers" :["A","B","C"]
"rows":[
["a","b","c"],
["d","e","f"]
]
}
Also following template:
<table>
<thead>
<tr>
<th ng-repeat="header in data.headers" ng-bind="header"></th>
</tr>
</thead>
<tbody>
<tr ng-repeat="row in data.rows">
<td ng-repeat="item in row track by $index" ng-bind="item"></td>
</tr>
</tbody>
</table>
I want to change
<td ng-repeat="item in row track by $index" ng-bind="item"></td>
to
<td ng-repeat="item in row track by $index" ng-bind="item" data-my-directive></td>
and get this:
<td data-title='C'>f</td> // `C` refer to headers[2], because f is row[2]
The main qusetion is, how to define a directive and force that replace (not add) the attribute, not whole HTML tag. (not how to access headers[2] value or something like that)
As we know, the template (or templateUrl) of a directive define a complete HTML tag structure (for example <div>SOMETHING</div>) and replace that (if replace: true) or append the template inside the caller tag.
Please note
Now I have no error or issue, everything working fine, but I need this solution to add more future to my code. I mean I got JSON data on the table and no problem with this part.