How to stop attribute to change case in html
let test1 = document.createElement('div');
test1.innerHTML = '<div [ngClass]>Test</div>';
console.log('--------dynamic', test1.innerHTML);
Here, [ngClass] change to ngclass.
How to stop attribute to change case in html
let test1 = document.createElement('div');
test1.innerHTML = '<div [ngClass]>Test</div>';
console.log('--------dynamic', test1.innerHTML);
Here, [ngClass] change to ngclass.
HTML attribute names are case-insensitive.
There is no way to stop browsers from normalising them when you give them some HTML to parse into a DOM and then serialise that DOM back to HTML.
If you want to process Angular's template language and maintain case sensitivity, then don't do so using tools that are designed to deal with HTML.
This code
test1.innerHTML = '<div [ngClass]>Test</div>';
is entirely pointless. Angular won't do anything with [ngClass]
.
Angular processes Angular specific markup only when it compiles a components template, but not when it is added to the DOM.
If you want to add Angular specific markup at runtime, you need to dynamically create and compile a component.
For more details see How can I use/create dynamic template to compile dynamic Component with Angular 2.0?