[英]Onclick in html-code vs find by id | How add value from php to js
[英]How to set the value of variable for id of HTML-element in HTML-code?
例如, counter
是我的變量。
我想做這樣的:
<input id="counter(I mean value of counter)" type="text" mozactionhint="next" name="sometext" />
或者,例如:
<table>
<tbody>
<tr *ngIf="currentNode?.parameters.length != 0">
<td align="center">Type</td>
<td align="center">Key</td>
<td align="center">Value</td>
</tr>
<tr *ngFor="let item of getParametersWithoutName(); index as i;">
<td>
<select>
<option>One-line</option>
<option>Multiline</option>
</select>
</td>
<td>< id="i (value of i)" input [ngModel]="item.name" (ngModelChange)="item.name = $event"/></td>
<td><input [ngModel]="item.value" (ngModelChange)="item.value = $event"/></td>
</tr>
</tbody>
</table>
如果要動態設置 angular 中元素的 id,可以使用括號表示法,如下所示:
// component.ts
counter = 1;
// template.html
<input [id]="counter"> </input>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.