[英]ngFor - Can't bind to 'testid' since it isn't a known property of 'input'. how to concat id with string?
我正在嘗試用我的 id 添加index
值。 但得到一個錯誤:
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}}">
我的代碼有什么問題? 有人幫我嗎?
我認為您將需要屬性綁定。 所以請嘗試替換下面的 testid 數據屬性。
<td ... [attr.data-testid]="'form-create-td-' + i">
對於帶有字符串的連接 id 屬性,您正在做正確的事情。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.