Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

angular2 getting value of custom attribute

I have input elements with a custom attribute call field.

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

On the change event, the currentField came back like this one the console.

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

I was able to do currentField.value to obtain the value, but I can't seems to figure out how to get the field value. What am I missing?

thanks for your time.

like image 234
chungtinhlakho Avatar asked Mar 06 '26 20:03

chungtinhlakho


1 Answers

There is the getAttribute(...) method for that on elements:

currentField.getAttribute('field')

See also getAttribute() versus Element object properties?

like image 58
Günter Zöchbauer Avatar answered Mar 09 '26 09:03

Günter Zöchbauer