【问题标题】:How to bind to data-* attribute in angular2? [duplicate]如何绑定到 angular2 中的 data-* 属性? [复制]
【发布时间】:2016-03-28 11:55:33
【问题描述】:

假设我有非常大的单元格网格,我想添加 data-row 和 data-col 属性值并从模型绑定。如何从 angular2(Dart 中的 beta0)绑定数据行。

与 data-row="{{boundVal}}" 绑定似乎不起作用。 (输出 html 中没有数据属性出现)

例如。

<table>
  <tr *ngFor="#row of rows" >
      <td *ngFor="#cell of row.cells" data-row="{{row.index}}" data-col="{{cell.index}}" >
      </td>
  </tr>
</table>

【问题讨论】:

  • 好问题 :-)

标签: angular angular-dart


【解决方案1】:

这应该做你想做的事

[attr.data-row]="row.index" [attr.data-col]="cell.index"

【讨论】:

  • @GünterZöchbauer 如何在点击事件中传递此数据行值?
  • 只要通过cell.index
猜你喜欢
  • 2015-07-11
  • 2017-04-28
  • 2016-08-26
  • 1970-01-01
  • 2016-11-22
  • 2015-09-28
  • 1970-01-01
  • 2018-02-10
相关资源
最近更新 更多