Do you have a component named "app-card-component"
?
I want to simplify things for you regardless of your level of understanding.
Usually, when displaying components with arrays, you would use *ngFor
. In this case, it could look like:
<app-card-component *ngFor="let card of oneByOneArray; index as i"><app-card-component>
(where oneByOneArray is the array where words are pushed one by one).
To show the words one by one, I recommend using a separate array to push the words to upon clicking.
When clicked, you can use the index i
from our *ngFor
to find the next word to add to our oneByOneArray.
A function to achieve this may look like:
pushWordWithIndex(i) {
this.oneByOneArray.push(this.originalArray[i] + 1);
}
You can then add a click event to the card as follows:
<app-card-component *ngFor="let card of oneByOneArray; index as i" (click)="pushWordWithIndex(i)"><app-card-component>
Pro tip:
Make sure to call the pushWordWithIndex function in ngOnInit or else no cards will be displayed. this.pushWordWithIndex(0);
.