简体   繁体   中英

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

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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