简体   繁体   中英

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.

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>

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM