After looking at the example provided here, I noticed that all three select options have the same value. How can I ensure that each option has a different selected value?
This is what I currently have:
<li ng-repeat="tarea in tareas">
<input type="checkbox" ng-model="tarea.COMPLETADA" ng-change="updTarea(tarea.ID)"/>
<span class="done-{{tarea.COMPLETADA}}" >{{tarea.NAME}} {{tarea.CLASIFICADORES}}</span>
<select ng-model="selectedOpt"
ng-options="clasificador.NAME for clasificador in clasificadores">
</select>
<button class="buttons delete right" ng-click="delTarea(tarea.ID)"> Eliminar</button>
</li>
I want to have 5, 10, or 15 options and make sure that each displays a different selected value based on tarea.CLASIFICADORES. I tried setting it with:
$scope.selectedOpt = $scope.clasificadores[1]
But this sets all the options to the same value, as shown in the example. How can I dynamically set different selected values for each option based on the data from my ng-repeat loop?
The data is loaded via ajax...
My main issue is setting the default selected item based on tarea.CLASIFICADORES. For instance, if I have a to-do list with classifiers, I want the ng-options to automatically select the classifier value from my database when the page loads.