简体   繁体   English

ngFor - 无法绑定到“testid”,因为它不是“输入”的已知属性。 如何将 id 与字符串连接?

[英]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.我正在尝试用我的 id 添加index值。 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.所以请尝试替换下面的 testid 数据属性。

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

For concatenation id property with string, you are doing right thing.对于带有字符串的连接 id 属性,您正在做正确的事情。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法绑定到“ ngFor”,因为它不是已知的本机属性 - Can't bind to 'ngFor' since it isn't a known native property “无法绑定到&#39;ngFor&#39;,因为它不是已知的本机属性” - “Can't bind to 'ngFor' since it isn't a known native property” 无法绑定到“*ngFor”,因为它不是“div”的已知属性 - Can't bind to '*ngFor' since it isn't a known property of 'div' 无法绑定到&#39;mdDatepicker&#39;,因为它不是&#39;input&#39;的已知属性 - Can't bind to 'mdDatepicker' since it isn't a known property of 'input' 无法绑定到“ngModel”,因为它不是“输入”的已知属性 - Can't bind to 'ngModel' since it isn't a known property of 'input' 无法绑定到“上载器”,因为它不是“输入”的已知属性 - Can't bind to 'uploader' since it isn't a known property of 'input' 无法绑定到“测试”,因为它不是“输入”的已知属性 - Can't bind to 'testing' since it isn't a known property of 'input' 无法绑定到“typeahead”,因为它不是“input”的已知属性 - Can't bind to 'typeahead' since it isn't a known property of 'input' 无法绑定到“matDatepicker”,因为它不是“输入”的已知属性 - Can't bind to 'matDatepicker' since it isn't a known property of 'input' 无法绑定到“shouldLabelFloat”,因为它不是“input”的已知属性 - Can't bind to 'shouldLabelFloat' since it isn't a known property of 'input'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM