Reputation: 114
I wan to create a html tag: <div ng-app></div>
, I try to use document.createElement('div')
to create the div
tag, but I don't know how to add ng-app
to the div
tag.
The function element.setAttribute(key, value)
doesn't fit my flavor here.
Upvotes: 0
Views: 50
Reputation: 635
Just pass an empty string as the second parameter for setAttribute.
var div = document.getElementsByTagName('div')[0];
div.setAttribute('ng-app','');
<div>Testing</div>
Upvotes: 1