Apache
Apache

Reputation: 105

Bind input and select to one ng-model

Have problem with binding model to input and select in the same time. Input value changes when model selected from dropdown. But dropdown doesn't change if entered input value equal some of the values of list.

Example on Plunker

<select 
  ng-model="Choice.SelectedOption"                 
  ng-options="choice.ID as choice.Name for choice in Choice.Options">
</select>

{{Choice.SelectedOption.ID}}
input model <input type="text" ng-model="Choice.SelectedOption">
input value {{ Choice.SelectedOption }}

Change model from dropdown, then try to change model from input to 1,2 or 3 (it's users ID's)

Upvotes: 0

Views: 266

Answers (1)

jitin
jitin

Reputation: 732

Changing <input type="text"> to <input type="number"> fixed it.

http://plnkr.co/edit/FQqVGZz51SCJunWPZwfd?p=preview

Upvotes: 1

Related Questions