I have a component and would like to render it as div or span dynamically. So I defined an input variable elementType. Now I would like to render it in a template.
Pseudo code:
<{{elementType}}>Content of the element</{{elementType}}>
This does of course not work, it`s a template rendering error. I could of course do something like
<div *ngIf="elementType == 'div'">Content of the element</div>
<span *ngIf="elementType == 'span'">Content of the element</span>
But I have to repeat myself with this, and in a more complex real world example, this is a mess.
What is a good way of handling this requirement?
display: inlineif you want them to behave as spans