How can i add arbritrary attributesto dom objects in the cli?

in ionic-cli i cannot just do

div.myProperty = “Hello”;

its works in normal html page with ionic script imports of course …

anyone got a solution ?

edit:

x.setAttribute("_name", customer );

works

but

i cannot

customersList.onclick = function (e) {

  console.log(e.target._name)

}

the e.target would be one of the ion-items (or just a div) in the list

getAttribute doesnt work on e.target either

edit2:

shit, doesnt work either… i cannot set any attribute … is null … ohh man whyi always have to struggle for hours on such shit

edit3:

and for android it doesnt even build …

Ok

x.setAttribute(“y”, “hello”)

this only works on normal HTML elements like div , not on ion-items, so just append a div to your ionic element to store arbritrary data corresponding to a list item or whatever

to get it back through event.target:

(event.target as HTMLElement).children[0].getAttribute(“y”)

then no need to count through lists and compare them to arrays, other wise you could only use the .id slot to set a reference point … this is easier when you have no need for complex angular models