I have a controller defined as
var searchController = function ($scope, $http) {
$scope.modSelectedState = null;
$scope.states = [];
$http.get('./data/states.js')
.success(function (data) {
$scope.states = data.locations;
})
}
Its job for now is to populate the list of states which I consume (successfully) from a local file.
Then, I have this code in my HTML file:
<select ng-model="modSelectedState" id="selectState" name="selectState"
ng-options="state as state.name for state in states">
<option value="">Select state...</option>
</select>
Which I cannot get to work. I know that my controller is defined properly and that the array is being populated successfully because i tried the following piece of code and it worked fine:
<ul ng-repeat="state in states">
<li>{{state.name}}</li>
</ul>
I placed this code right before the options code under the scope of the same controller of course.
A JSON object in my array looks like this:
{
"lat": 35.02499,
"long": -84.92153,
"name": "Alabama",
"short": "AL"
}
Cannot figure out why it is not working..