如何绑定到数据 - *在angular2属性? [英] How to bind to data-* attribute in angular2?

查看:220
本文介绍了如何绑定到数据 - *在angular2属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有真正的大网格我想从模型中添加数据行和数据山坳属性附加伤害值和绑定细胞。我怎样才能将数据绑定行从angular2(在DART beta0)。

数据行绑定={{boundVal}}似乎并没有工作。
(无数据属性出现在输出HTML)

如:

 <表>
  < TR * ngFor =#排排>
      < TD * ngFor =#row.cells细胞的数据行={{row.index}}数据-COL ={{cell.index}}>
      < / TD>
  < / TR>
< /表>


解决方案

这应该做你想要什么

  [attr.data行] =row.index[attr.data-COL] =cell.index

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>

解决方案

This should do what you want

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

这篇关于如何绑定到数据 - *在angular2属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆