110

Assuming I have really large grid of cells I want to add data-row and data-col atribute values and bind from model. How can I bind data-row from angular2 (beta0 in Dart).

Binding with data-row="{{boundVal}}" does not seem to work. (no data attribute appears in output html)

eg.

<table>
  <tr *ngFor="#row of rows" >
      <td *ngFor="#cell of row.cells" data-row="{{row.index}}" data-col="{{cell.index}}" >
      </td>
  </tr>
</table>
1
  • Good question :-) Commented Oct 22, 2020 at 9:54

1 Answer 1

242

This should do what you want

[attr.data-row]="row.index" [attr.data-col]="cell.index"
Sign up to request clarification or add additional context in comments.

2 Comments

@GünterZöchbauer How can I pass this data-row value in click event?
just pass cell.index

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.