I'm trying to figure out why the ng-model is not working with the ng-repeat.
There is my code:
$scope.availableCountries = []; APIUtility.getCountries().then(function(data){ $scope.availableCountries = data; $scope.filters.country = "AZ"; }); <select id="eventprice" class="searchpage_select" ng-model="filters.country"> <option value="all">show all</option> <option ng-repeat="countries in availableCountries" value="{{countries.country_iso}}" ng-class="{'element_selected' : filters.country == countries.country_iso}">{{countries.name}}</option> </select> where:
availableCountries is an object from an API call (well formed, trust me)
$scope.filters is an object containing a lot of filters (including country)
The problem is that if i change the ng-model before or after the API call, the select statement is not updated, i think that if i update the scope before angular has the time to execute his ng-repeat, ng-model stop working and will not update the field.
i added the ng-class to prove that filters.country has the right value (ng-class statement returns true when needed and add the class in the right place, so filters.country contains the right value).
I don't know if i was clear enough. Thanks all for your time!