本文介绍了ngFor - 无法绑定到“testid",因为它不是“input"的已知属性.如何用字符串连接id?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用我的 ID 添加 index
值.但得到一个错误:
I am trying to add the index
value with my ids. but getting an error as:
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}}">
我的代码有什么问题?有人帮帮我吗?
what is wrong with my code? any one help me?
推荐答案
我认为您将需要属性绑定.所以请尝试替换下面的 testid 数据属性.
I think you will need property binding. So please try to replace below testid data property.
<td ... [attr.data-testid]="'form-create-td-' + i">
对于带有字符串的连接 id 属性,您做对了.
For concatenation id property with string, you are doing right thing.
这篇关于ngFor - 无法绑定到“testid",因为它不是“input"的已知属性.如何用字符串连接id?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!