我试图获取输入标签的值,但是我总是收到资产名称。有人可以帮助我吗?非常感谢。
Activity-1
- Phase-1
- Risks
- Risk-1
- PPMS
- Risk-2
- PPMS
- Tools
- Tool-1
- Risk-1
- Risk-2
答案 0 :(得分:1)
您可以在(input)
元素上使用<input>
,例如:
<select class="form-control" [(ngModel)]=id name="assetID">
<option *ngFor="let asset of arrAssets; let i = index;" selected>
<input type="hidden" (input)="inputChanged($event , i)" value="{{ asset.Id }}" name="id">
{{ asset.Name }}
</option>
</select>
如果您想自己检测每个输入,我已经将i
添加为索引
移动到.ts
文件
export class Home {
constructor(){}
inputChanged(eve, i) {
console.log(eve.target.value); // This should print the value of input element
console.log(i); // This should print the index of input element which has changed
}
}