Issue
How to achieve a .map
of react with angular.
Example at React:
const options = ['Car', 'Bus', 'Truck', 'Bike', 'Motorcycle'];
const compTest = () => (
<select>
{options.map((vehicle) => <option>{vehicle}</option>)}
</select>
)
How I do this with an angular component?
Solution
In your component.ts file
options = ['Car', 'Bus', 'Truck', 'Bike', 'Motorcycle'];
in your component.html file
<select>
<option *ngFor="let option of options">{{option}}</option>
</select>
and here is StackBlitz
https://stackblitz.com/edit/angular-ivy-nrzght