A
A
Alexander Kovalchuk2015-07-28 14:03:41
Angular
Alexander Kovalchuk, 2015-07-28 14:03:41

How to pick up only id from select using angular?

I'm creating a form, I ran into a problem that for the select tag I have an id and a name, I show the name to the user and, depending on his choice, I have to write in json id, but I get the whole array from the name and id. How can I make it record only id?

<div class="form-group">
      <label>Пример: </label>
      <select ng-model="user.example" 
                 ng-options="example.name for example in examples" 
                 class="form-control" 
                 ng-value="example.code" 
                 required></select>
    </div>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2015-07-28
@mamut

<select  ng-model="user.example" 
              required 
              ng-options="example.id as example.name for item in examples"
></select>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question