[英]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.