I am working with a custom library component called <my-icon>
. To display the icon, I need to specify the property [name]
like this:
<my-icon [name]='warning'></my-icon>
Currently, I am dynamically creating these icons in TypeScript:
if (myCondition) {
let icon = <HTMLElement>document.createElement('my-icon');
}
How can I set the [name]
property on my variable icon
to achieve the same result as above? I have tried using
icon.setAttribute('name','warning')
, but it seems to only set the HTML attribute name
rather than the input name
of the Angular component underlying it.