[Fixed] How can I make a map in Angular?


How to achieve a .map of react with angular.

Example at React:

const options = ['Car', 'Bus', 'Truck', 'Bike', 'Motorcycle'];
const compTest = () => (
    {options.map((vehicle) => <option>{vehicle}</option>)}

How I do this with an angular component?


In your component.ts file

options = ['Car', 'Bus', 'Truck', 'Bike', 'Motorcycle'];

in your component.html file

  <option *ngFor="let option of options">{{option}}</option>

and here is StackBlitz

Leave a Reply

(*) Required, Your email will not be published