I have a lot of card component they are different type. I am getting data of card list from a json array.
[
{id: 1, type: "flower"},
{id: 2, type: "tree"},
{id: 3, type: "animal"}
]
And I have created Angular components of these types:
<flower></flower>
<tree></tree>
<animal></animal>
So I want to add these as dynamically in my app.componnet.html template.
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
data: any;
ngOnInit(){
this.data = [
{id: 1, type: "flower" },
{id: 2, type: "tree" },
{id: 3, type: "animal" }
];
}
}
my json data comes from server.