How to add select form element in Angular html component file?

.ts:

  all_lines = [
    {id: 1, name: "Line 1"},
    {id: 2, name: "Line 2"},
    {id: 3, name: "Line 3"},
    {id: 4, name: "4"},
    {id: 5, name: "5"},
    {id: 6, name: "6"},
    {id: 7, name: "7"},
    {id: 8, name: "8"},
    {id: 9, name: "9"},
  ];

.html:

<select formControlName="lines" class="form-control">

<option *ngFor="let line of all_lines" [ngValue]="line.id">{{line.name}}</option>

</select>

Leave a Reply

Your email address will not be published. Required fields are marked *