Hey there, I'm currently working on the following:
$scope.test = [
{"value" : 0, "text" : "00:00"},
{"value" : 900, "text" : "00:15"},
{"value" : 1800, "text" : "00:30"}
];
and in my select element, this is what I have:
<select ng-model="monday.morning" ng-options="obj.value as obj.text for obj in test">
which gives me the following options:
<select ng-model="monday.morning" ng-options="obj.value as obj.text for obj in test">
<option value="?" selected="selected"></option>
<option value="0">00:00</option>
<option value="1">00:15</option>
<option value="2">00:30</option>
</select>
My goal is to match the values from the JSON array with the option values and have the first one selected. Can it be achieved like below?
<select ng-model="monday.morning" ng-options="obj.value as obj.text for obj in test">
<option value="0" selected="selected">00:00</option>
<option value="900">00:15</option>
<option value="1800">00:30</option>
</select>
Essentially, making sure the option values match those in the 'test' array.