13

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,443
  • 7
  • 41
  • 69
BrianM
  • 851
  • 2
  • 12
  • 28
  • 2
    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

22

Use this instead:

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

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

stormdrain
  • 7,910
  • 4
  • 36
  • 75
Chifti Saidi
  • 376
  • 3
  • 7