繁体   English   中英

ngFor - 无法绑定到“testid”,因为它不是“输入”的已知属性。 如何将 id 与字符串连接?

[英]ngFor - Can't bind to 'testid' since it isn't a known property of 'input'. how to concat id with string?

我正在尝试用我的 id 添加index值。 但得到一个错误:

Can't bind to 'testid' since it isn't a known property of 'input'.

这是我的模板:

<td *ngFor="let col of columns; let i = index"  [ngClass]="col.class" data-testid="form-create-td-{{i}}">

我的代码有什么问题? 有人帮我吗?

我认为您将需要属性绑定。 所以请尝试替换下面的 testid 数据属性。

<td ... [attr.data-testid]="'form-create-td-' + i">

对于带有字符串的连接 id 属性,您正在做正确的事情。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM