I've created a list component, running successfully through an array of items and outputting its data through an *ngFor loop.
now I want to reuse this component and add more possible arrays of data to choose from. for that, an @input was created, allowing me to pass the array name "on" the component wherever it's used, but when I try to pass it to the *ngFor I get an error.
my ts code is:
@Input() listName : string;
list1: any = [
{title: 'title1'},
{title: 'title2'},
{title: 'title3'},
]
list2: any = [
{title: 'titlea'},
{title: 'titleb'},
{title: 'titlec'},
]
the component looks like this:
<app-listcomp listName="list1"></app-listcomp>
I can figure that this is not a correct syntax inside the component:
*ngFor="let listItem of {{listName}}"
but can't quit find what is the correct way to pass the array name through the @Input (or any other correct way).
when I use the specific array name in the *ngFor loop - it works perfectly of course.