Noname135
Noname135

Reputation: 101

How to display an array of objects in with typescript?

I'm very new to typescript.

I've got a wrapper component, and a bunch of child components that I want to display.

So, something like this is in my parent component html: <component-card [someData]=someData></component-card> works just fine and displays my component. But how do I display a list of them?

Simply doing <li *ngFor="let card of componentCardArray"></li> doesn't work. I tried different ways

Most tutorials just cover simple types, I searched for hours and can't find a way to do it.

Upvotes: 0

Views: 1840

Answers (1)

Noname135
Noname135

Reputation: 101

Okay, I figured it out! I was forgetting to put the selector after the whole *ngFor directive thing. So, here is how my components are displayed now in my wrapper.html:

 <div *ngFor="let card of cardArray">
      <component-card [myData]=myData></component-card>
</div>

Upvotes: 1

Related Questions