本文介绍了ngFor-无法绑定到"testid",因为它不是"input"的已知属性.如何用字符串连接id?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将 index
值添加到我的ID中.但收到错误消息:
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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!