1

With ng-options the selectedCar will be a car object

<select 
    ng-model="selectedCar" 
    ng-options="car as car.description for car in cars track by car.id">
</select>

With ng-repeat the selectedCar wont be a car object and a need this object to future reference. I need to use title atribute and ng-options don't support this. How can i keep car object in option with ng-repeat?

<select>
    <option
        ng-model="selectedCar"
        ng-repeat="car in cars" 
        value="{{car}}" 
        title="{{car.description}}">{{car.description}}
    </option>
</select>

http://jsfiddle.net/g9yW2/2/

thiagoaos
  • 61
  • 4

1 Answers1

0

This looks like what you're looking for: Initializing select with AngularJS and ng-repeat This example also helped me: https://docs.angularjs.org/api/ng/directive/select

Community
  • 1
  • 1
Chris Ubick
  • 123
  • 11
  • This don't help me. I did a example. I would like to use ng-repeat with select options and keep the selected car as object and not a json. http://jsfiddle.net/g9yW2/2/ – thiagoaos Aug 04 '14 at 12:28