I'm trying to call dynamic components in ngFor, but i cannot use variables inside Tags HTML.
What i have:
components = [component1, component2, component3];
<div *ngFor="let component of components">
<component></component>
</div>
Result i want:
<component1></component1>
<component2></component2>
<component3></component3>
Result i get:
<component></component>
<component></component>
<component></component>
You won't be able to do it that way. You'll have to use the component loader:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.