Currently I'm struggeling by setting the default value for a ng-options in angularjs. Can somebody help me?
I get the Options from a resource.
<select id="customer_country" ng-model="customer.country" ng-options="country.name for country in countries" style="width:230px;">
</select>
My current workaround is to set the default like this:
$scope.countries = Country.query(function() {
$scope.customer.country = $scope.countries[0];
});
But I don't think its the best way to do it. I searched the internet but didn't find a good answer. How would you assign the default value?
Currently I need this that it don't has a null value. Also sometimes it won't have a null value and it shouldn't use the value that is in the model to update the model.