15

I create elements with the var l = document.createElement("label"); and I assign its attributes with l.setAttribute("formControlName","e");. The problem is that the setAttribute method puts the formControlName in lowercase letters as you can see in the image below. I work with ionic so the capital letters are needed. Does anyone see what I did wrong?

enter image description here

enter image description here

mvermand
  • 5,829
  • 7
  • 48
  • 74
BrianM
  • 951
  • 2
  • 12
  • 29
  • 3
    Possible duplicate of [Camel case in HTML tag attributes and jquery - doesn't work, why?](https://stackoverflow.com/questions/36176474/camel-case-in-html-tag-attributes-and-jquery-doesnt-work-why) – Adelin Jan 17 '18 at 11:59
  • 1
    Do you have a reference for "ionic so the capital letters are needed"? I find that hard to believe. – Nickolay Jan 23 '18 at 16:37
  • This is rather a requirement of Angular which is a framework below Ionic. – mvermand May 08 '20 at 07:20

1 Answers1

27

Use this instead:

l.setAttributeNS(null, "formControlName","e");

'setAttributeNS()' doesn't convert the name to lower case.

stormdrain
  • 7,915
  • 4
  • 37
  • 76
Chifti Saidi
  • 438
  • 5
  • 9