Angular2获取自定义属性的值

angular2 getting value of custom attribute

本文关键字:自定义属性 获取 Angular2      更新时间:2023-09-26

我有一个带有自定义属性调用字段的输入元素。

<input type="text" (change)="recordChange(currentField,row)" #currentField field="caution">

在更改事件中,currentField像这样返回到控制台。

 <input type="hidden" field="caution" value="plus icon red"> 

我可以做currentField。值获取值,但我似乎无法弄清楚如何获得字段值。我错过了什么?

感谢您的宝贵时间。

在元素上有getAttribute(...)方法:

currentField.getAttribute('field')

参见getAttribute()与Element对象属性?