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

淺唱寂寞╮ 提交于 2019-12-13 03:18:00

问题


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'.

here is my template:

<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?


回答1:


I think you will need property binding. So please try to replace below testid data property.

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

For concatenation id property with string, you are doing right thing.



来源:https://stackoverflow.com/questions/58776401/ngfor-cant-bind-to-testid-since-it-isnt-a-known-property-of-input-how-t

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!