I'm new to Angular. I do not quite understand how *ngFor works in angular. Apperantly, you can only use it if you iterate through an array of objects and not only for an array. For my project, I need to go through an array that contains some IDs. Depending on that ID I will apply a badge. Somehow it only works for one and not for multiple. I hope i explained it properly, ask for more information if it's not clear what I tried to explain. ids_pic
1 Answer
@Component({/**/})
class MyComponent {
public myArray: number[] = [11,12];
}
html:
<!-- ng-container for no html but with eaching -->
<ng-container *ngFor="let number of myArray">
<div>{{number}}</div>
</ng-container>
or like this:
<!-- only one decorator with * per html block, for more when one - use ng-container -->
<div *ngFor="let number of myArray">{{number}}</div>