Search code examples
angularangular5chained-select

Angular 5 select options from function


I'm trying to figure out how to do chained selects with Angular 5. This is what I have so far. The first select works, the second one is not.

<select [ngModel]="selectedTag" (change)="tagChanged()" [disabled]="!element.checked">
  <option *ngFor="let tag of tags">
    {{tag}}
  </option>
</select>

<select multiple="multiple" class="stations">
    <option *ngFor="let station of stationsByTag()">
        {{station}}
    </option>
</select>

I think the stationsByTag() is only being called once.


Solution

  • I don't know what stationsByTag() looks like but you likely need to set a currentTag on the component when it's selected and update stationsByTag based on that.