g3k0
g3k0

Reputation: 157

Angular 2 select editable

I have a simple select like this:

<select [style]="{width : '100%' }" [(ngModel)]="rule.valoreImmesso" class="lm-custom-dropdown">
      <option *ngFor="let valore of rule.comboValues" [value]="valore.value">{{valore.label}}</option>
</select>

I want to add an input text inside the dropdown in order to filter the options. Is it possible? How to do it?

Upvotes: 1

Views: 2153

Answers (1)

Ram_T
Ram_T

Reputation: 8484

You can do like this

<input type="text" list="cars" [(ngModel)]="rule.valoreImmesso"/>
<datalist id="cars">
  <option *ngFor="let valore of rule.comboValues" [value]="valore.value"></option>
</datalist>

But datalist tag not supported in Safari So you must write a custom dropdown on your own. You can find some in the internet and modify them as you desired.

Upvotes: 1

Related Questions